Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. They exist physically but are corrupt.
  2. 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?
  3. Yep. All there! Seems really odd.
  4. 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.
  5. Thanks all. So if I don't set a check then it'll void of any permissions? Great.
  6. 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?
  7. 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(); }
  8. 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?
  9. Yes, sorry. PW 3.0.62, PHP 5.6.37, mySQL 5.7.17 I'm using the admin interface for importing.
  10. I'm attempting to add over 300 images to an image field but when I add them all I get the following errors... The images are around 200kb each. My php.ini settings are fairly high. Any thoughts? Am I able to stop simultaneously uploads and add one at a time (which I think is what the issue is).
  11. Yes good thinking. Maybe I do a select form field with a post variable to the current page. That might be better so I don’t need to have ? in the URL.
  12. An odd question but I'm curious. Is it possible to use multi-language without URL changes? So it'll only show a different page title and/or content based on what the $user-language is set to? In a nutshell I want to use the multi-language functionality to display different prices/currencies (executed via a function) and it requires from server side conditioning that multi-language is perfect for. I've got it currently set up as follows: <select onchange="window.location=$(this).val();"> <?php foreach ($languages as $language) : ?> <?php $url = $page->localUrl($language); ?> <option <?php if ($user->language->id == $language->id) : ?>selected<?php endif; ?> value="<?php echo $url; ?>"><?php echo $language->title; ?></option> <?php endforeach; ?> </select> However when I check what the $user->language is upon different selections it's always the same (default).
  13. Thanks for everything everyone. Much appreciated ?
  14. Amazing. I did the following: $wire->addHookMethod('Page::shopifyRelatedProducts', function($event) { $page = $event->object; $shopifyProductIds = $event->arguments(0); $result = wire('cache')->get('shopifyRelatedProductsForPage' . $page->id, WireCache::expireHourly); if (!$result) { $result = $this->http->getJSON($this->shopifyBase . "products.json?ids=$shopifyProductIds"); wire('cache')->save('shopifyRelatedProductsForPage' . $page->id, $result, WireCache::expireHourly); } $event->return = $result; }); Which seems to work but how can I check it's loading the cached version? Do you know where the WireCache files are saved? EDIT I guess it has worked!
  15. Yes! This is great! ? Thanks everyone. A final thing. I was using phpFastCache before but I'd like to use the in-built $cache. I'm guessing this is possible within a hook? Just so I can cache the API JSON every 30 minutes or so.
  16. Thanks again! Apologies for not explaining but I meant using different parameters in the template like a standard PHP function: $page->customProperty(2) or $page->customProperty(1373, 1786) with the arguments being different each time. For example say I created this hook in ready.php $this->http = new WireHttp(); $this->host = 'xxx.myshopify.com'; $this->shopifyAPIKey = 'xxx'; $this->shopifyPassword = 'xxx'; $this->shopifyBase = 'https://' . $this->shopifyAPIKey . ':' . $this->shopifyPassword . '@' . $this->host . '/admin/'; $wire->addHookProperty('Page::shopifyRelatedProducts', function($event) { $page = $event->object; //$event->return = $this->http->getJSON($this->shopifyBase . 'products.json?ids=632910392,921728736'); $event->return = $this->http->getJSON($this->shopifyBase . "products.json?ids=$shopifyProductIds"); }); On a template (say home.php) when I call the new hook property how would I pass in the arguments for the parameter $shopifyProductIds? $ids = "123456,789101" $page->shopifyRelatedProducts($ids);
  17. Amazing. And do you know if it’s possible to pass patamters into addHookProperty to pass an ID, for example, from when it’s used at the template end? So I can use the property but set different parameters.
  18. Thanks. So if I set an array in ready.php I could essentially access it in a template if the hook context is correct?
  19. Is it possible to create a hook in ready.php that can also be used in a template? I’m using a REST API for Shopify to create pages in the backend (a list of products) but I also want to loop this list of products in a template file. I don’t want to have to write two hook functions that is essentially the same code. My hook is set to fire via lazyCron every 30 mins (LazyCron::every30Minutes)
  20. I attempted just to do a standard PHP fetch for the RSS to check if it had any errors... Warning: DOMDocument::load(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /www3/453/www.modernshows.com/web/test.php on line 16 Warning: DOMDocument::load(): Failed to enable crypto in /www3/453/www.modernshows.com/web/test.php on line 16 Warning: DOMDocument::load(https://insidemodernism.co.uk/feed/): failed to open stream: operation failed in /www3/453/www.modernshows.com/web/test.php on line 16 I can obviously turn this off with the following (which isn't ideal) but unsure how to fix properly especially for this module. stream_context_set_default([ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false ] ]);
  21. Dumping $event doesn't seem to do anything so perhaps InputfieldSelect::processInput isn't right? Should it be InputfieldWrapper::processInput?
  22. Thanks for your help, @bitpoet. It seems like adding 'InputfieldSelect::processInput' breaks it (doesn't return any options).
  23. I also tried the following from this topic https://processwire.com/talk/topic/14463-fieldtypeoptions-set-selectable-options-through-api/ $wire->addHookBefore('InputfieldSelect::render', function($event) { if ($event->object->hasField == 'work_detail_videos_image') { $repeaterPage = $event->object->hasPage; $page = $repeaterPage->getForPage(); $options = $event->object->getOptions(); foreach($page->work_detail_images as $image) { if ($image->ext == 'GIF' || $image->ext == 'gif') { $option = new SelectableOption(); $option->title = $image->name; $options->add($option); } } $event->object->setOptions($options); } }); But it errors out with "Call to a member function add() on array"
  24. Thanks! Got this working with your help. Only issue now is that it doesn't seem to 'save' the selections by the user when saved. Is that because it's 're-adding' them each time?
  25. Thanks so much. Okay... this makes sense. Unfortunately 'work_detail_images' isn't in the repeater. I guess I'll need to hook into the repeater too?
×
×
  • Create New...