• Content Count

  • Joined

  • Last visited

Community Reputation

61 Excellent

About a-ok

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks folks. I tried this but received an error: Using $this when not in object context function shopifyInit(HookEvent $event) { 83: 84: $collections = $this->shopifyHttp->getJSON($this->shopifyBase . "custom_collections.json"); I'm using $this to grab my API keys etc outside of the scope of the hook $this->shopifyHttp = new WireHttp(); $this->shopifyAPIKey = blahblah Using $this works fine when using it directly in a hook but not within a function that's called within a hook?
  2. I had a hook method set up to do a few things, hooked to a lazycron of every 30 minutes: wire()->addHook('LazyCron::every30Minutes', function($event) { // functions etc } This was working fine but I needed to call the content of the function on a specific page save also so I made it into a public function and set up two hooks for it... one on the lazycron and one on page. function shopifyInit(HookEvent $event) { // functions etc } wire()->addHook('LazyCron::every30Minutes', null, 'shopifyInit'); wire()->addHookAfter('Pages::save', function($event) { $page = $event->arguments(0); if ($page->template->name == 'shop') { // Shop shopifyInit(); $page->message('Shopify cache has been cleared for all products'); } }); However on save I am getting this error... ArgumentCountError Too few arguments to function ProcessWire\shopifyInit(), 0 passed and exactly 1 expected Any thoughts where I'm going wrong?
  3. Just a quick q. re https://processwire.com/docs/security/sessions/ – is this also related to https://processwire.com/api/ref/session/ – so if I was to create a session it would store it on the DB instead? I'm just thinking this could be useful for HTML5 sessionStorage etc. Thanks!
  4. Turns out I had to set the sort before the return... if ($page->template->name == 'projects-overview') { foreach($page->children() as $child) { if ($child->detail_dates_date_sort === '') { $child->detail_dates_date_upcoming = $child->getUnformatted('created'); } else { $child->detail_dates_date_upcoming = $child->getUnformatted('detail_dates_date_sort'); } } $page->children()->sort('-detail_dates_date_upcoming'); $event->return = $page->children(); }
  5. I thought this would be fairly trivial but it's not giving the expected results. I want to sort a parent/child set up in the admin page tree (I need to sort by multiple selectors, which the admin doesn't allow, so doing it via a hook) This is what I have as my hook: function hookPageTreeFind(HookEvent $event) { $page = $event->arguments('page'); if ($page->template->name == 'projects-overview') { foreach($page->children() as $child) { if ($child->detail_dates_date_sort === '') { $child->detail_dates_date_upcoming = $child->getUnformatted('created'); bd($child->title . ' ' . date('l j F Y', $child->detail_dates_date_upcoming)); } else { $child->detail_dates_date_upcoming = $child->getUnformatted('detail_dates_date_sort'); bd($child->title . ' ' . date('l j F Y', $child->detail_dates_date_upcoming)); } } $event->return = $page->children("sort=detail_dates_date_upcoming"); bd($event->return); } } wire()->addHookAfter('ProcessPageList::find', null, 'hookPageTreeFind'); It loops through each child page and grabs the date field 'detail_dates_date_sort' and sets that as the sort value. The date field is sometimes left blank so I set the sort value as the created date. I'm doing a bit of debugging (hence the bar dumps) and you can see from this screenshot that the order is messed up? The child at the end of the screenshot 'Black Quantum Futurism' has no date field set so thus outputting, correctly, the created date. Any pointers to where I'm going wrong? Thanks.
  6. a-ok

    That's fine I don't allow for image insertions on text fields. Thanks again everyone for helping me resolve this.
  7. a-ok

    Yes this fixed things. Thanks for the heads up. I guess it's no drama if it removes variations of ones that weren't corrupt, right?
  8. a-ok

    They exist physically but are corrupt.
  9. I ran into an issue on my server with the PHP GD library and all my thumbnails on image fields are now transparent (see attached). Is there a way to regenerate these thumbnails without re-uploading all the images again?
  10. I'm uploading around 300+ images to an image field across a few pages. They show in the backend, and using TracyDebugger I can see all the images (see attached) but on the front end they're returning a count of zero like they don't exist. I can't seem to be able to delete an image from it either (it just keeps showing after deleting and saving). `bd($pages->get(1057)->gallery_topic_images)` returns a count of 0. They show in the database too. It's only on the front end that it's an issue. Do you think I have too many images? Is it crashing out on the front end? Previously sections using the same field seem to work fine.
  11. Thanks all. So if I don't set a check then it'll void of any permissions? Great.
  12. If I set the admin user in the backend to not have rights to create pages for a certain parent/child tree... can the API still publish/create? Is the API void of permissions/roles?
  13. I have a JSON multi-dimensional array of products from Shopify that I am looping through. Each product has 3 options and each option can have infinite numbers of values. For example: Lamp (product) Glass Finish (option) Clear (value) Smoke (value) Metal Finish (option) Polished Chrome (value) Drop (option) 600mm (value) 800mm (value) Within the loop I am creating rows within a repeater field (one for each option and then a repeater within each option for each value). This is all fine BUT I want to do a few checks as the array of products is cached to every 30 minutes so if the cache was updated and either an option was removed or a value to that option was added then it should update. I have my first check in place (loop through all the existing repeater options that have been added, before doing anything, and if an option already exists then skip it (and thus not creating multiple of the same options). What I need to do is to check each of the values to see if any new ones have been added. I can write the code to actually add the value to the repeater field but I am unsure how to check as by this point, if the option already exists, it skips over. foreach($product['options'] as $option) { foreach($p->shop_product_options as $options) { // If this option already exists... then skip the parent loop on this product if ($options->global_text == $option['name']) { continue 2; } } $options = $p->shop_product_options->getNew(); $options->of(false); $options->global_text = $option['name']; $options->save(); $p->shop_product_options->add($options); foreach($option['values'] as $o) { $values = $options->shop_product_options_option->getNew(); $values->of(false); $values->global_text = $o; $values->save(); $options->save(); $options->shop_product_options_option->add($values); } $options->save(); }
  14. I’ve upgraded PHP to 7.1 and PW to the latest. Still the same issue. I wonder if I could create the pages (and thus the assets folders) and dump the images in there and hook them up that way?