Jump to content

prestoav

Members
  • Posts

    189
  • Joined

  • Last visited

1 Follower

Contact Methods

  • Website URL
    http://www.prestoav.com

Profile Information

  • Gender
    Male
  • Location
    Ely, Cambs UK
  • Interests
    Consumer tech, guitars, rock 'n' roll, classic cars

Recent Profile Visitors

3,058 profile views

prestoav's Achievements

Sr. Member

Sr. Member (5/6)

115

Reputation

2

Community Answers

  1. @Robin S Ah ha, nailed it! My bad for not reading that part of the description. Now changed to checkboxes and it's working a charm. Thanks again for your help. Seriously useful!
  2. Hi @Robin S, Many thanks. This has cured the saving error for sure. It doesn't address the full tree being shown when you go to select a page but I'm not sure that's even possible. Again, every day is a school day. I had seen and used the 'page.field' format in selectors before but not the 'page.page' one. I also wasn't aware that '$page' could be substituted with 'page' in these selectors so thanks for that lesson too! G.
  3. Hi @elabx, Thanks so much for showing these examples I'm not great with page hooks yet but I'm getting there. I'm going to look deeper into you examples and have a play!
  4. Hi all, I'm building a categorised FAQ section for a site with the following structure: -FAQ Page (template = faq-parent) -- Category 1 (template = faq-category) -- Category 2 (template = faq-category) etc. -- Questions (template = faq-articles) --- Question 1 (template = faq-article) --- Question 2 (template = faq-article) etc. The 'Questions' page is a container for all the actual question pages (articles) to make admin clearer as there are likely to be 100+ question pages / articles. I'd like to make the system so I can duplicate it elsewhere in the same website as we might have more than one FAQ section using the same templates and page structure. Each article has a page reference field where the editor can choose one or more categories for the article to be listed under. So, to ensure flexibility, I'd like this field to only select from categories that are under the main 'FAQ' page grandparent of the actual article. This would ensure that a second FAQ section would not conflict with the first. Setting up the page reference field for the article category I would usually set parent and template in the 'Selectable Pages' fieldset. However, setting the parent would restrict the flexibility of the system to just this FAQ section (because the parent is pre-set). So, trying to use the 'Selector String' method I added the selector: template=faq-category, parent=$page->parent->parent, sort=sort But I get this error when saving an article page with a chosen category: PagesEditor: Error saving field "Categories this question is displayed in" — Unrecognized operator: $ Also, when selecting the category on the article page, the whole page tree is displayed rather than the sub set of pages found by the selector. Does anyone have any ideas how this might be done or will I need to leave the field selection open for any page? All thoughts gratefully received!
  5. Hi Zeka, Thank you for the suggestion. Sadly that just gives a blank array and the error 'Notice: Array to string conversion'. Stay safe my friend.
  6. Hi all, PW 3.0.184 On trying to diagnose a form issue it's become clear that the PW $session array is empty. $_SESSION has data in it but PW's own $session variable is empty, not even the User ID is there? For example adding this at the top of any page: <?php print_r($session); ?> Results in this: ProcessWire\Session Object () But this: <?php print_r($_SESSION); ?> Outputs user and other data. I'm trying to use some data that woudl be way easier using PW's $session and am drawing a blank. Grateful of any ideas or past experiences which may help diagnose this!
  7. Hi @horst Thanks for your repay. $config->debug is on and no errors there. I've also checked logs and nothing showing up there either sadly 😞 I've also uninstalled the 'Page Rename Options' module in case that was interrupting the process but that made no difference either. Finally I've updated the client server to PHP 7.4.21 but that didn't change anything.
  8. Hi Andreas, Thanks for the information and glad I'm not alone! I just tried a copy on my local MAMP install (PHP 7.4.21) and that worked just fine. On the client's DV server (PHP 7.3.33) it won't work. I'm not keen to change the client's PHP version yet but I could if it comes to that.
  9. Hi there, PW 3.0.165 I have a multi-language site where I need to change the URL slug / name of the page. Current names are: /en/page-name /fr/page-name /de/page-name etc. ('page-name' is actually something else) I go into the page in admin and change (under settings) to the following: /en/page /fr/page /de/page (again, 'page' is something else but just a single word, no spaces or special chars) But when I save the page and look again all the names are back to: /en/page-name /fr/page-name /de/page-name etc. Is there a template setting or similar I have missed where you can prohibit name changes? I'm not getting any warnings about it and I can't see one but I'm sure I'm missing something! Any help really appreciated!
  10. Hi @Robin S this is super helpful and makes complete sense. I was arriving at that conclusion but your explanation and examples really help. When I have it working I'll post final code here for anyone looking in future.
  11. Hi @Robin S Thanks again for the code above, really useful. I'm getting a lot of this to work now except the actual the actual upload of the file itself. The list of file names generates properly to the $_POST['images'] and is readable and correct if you print_t the $image_names. However, the image isn't uploading and I'm getting this error : Error: Exception: Unable to read: /site/assets/files/21526/img-1.png (in wire/core/Pagefile.php line 230) There is no file uploaded to that directory. Note: 21526 is the page ID, img-1.png is the correct name for the uploaded image. Further down the error text the issue seems to originate from this line: $pageimages->add($pageimage); Here's my full PHP ($pte is the page itself assigned elsewhere and tested as working): // Update Images // Look for the comma separated value in POST $images_value = $_POST['images']; // If the value exists then the form was submitted & we need to update image fields if($images_value != '') { // Explode the comma separated value to an array of image basenames $image_names = explode(',', $images_value); // Add empty images if no image added or removed if (count($image_names) < 4) { $blanks = 4 - count($image_names); while ($blanks > 0) { array_push($image_names, ""); $blanks = $blanks - 1; } } // Create a Pageimages object using the individual image basenames $all_images = new Pageimages($pte); foreach($image_names as $image_name) { $all_images->add($image_name); } // Turn off output formatting because we are about to set field values $pte->of(false); // Loop over the image basenames foreach($image_names as $index => $image_name) { // Get the Pageimage from $all_images $pageimage = $all_images->get($image_name); // Create a new empty Pageimages object $pageimages = new Pageimages($page); // Add the Pageimage if ($pageimage != '') { $pageimages->add($pageimage); // Determine the field name that will be updated if ($index == 0) { $image_field_name = 'page_image'; } else { $image_field_name = 'product_image_' . $index; } // Set the field value $pte->$image_field_name = $pageimages; } } } $pte->save(); You'll see I've added blanks to fill in empty / missing fields as the front end form allows for images to be deleted so I need to populate those with no image if they have been deleted. Also, you'll note that the first image field to upload to has a different name. This is a legacy issue I'm dealing with... Any ideas on why the image isn't being uploaded would be really helpful!
  12. OK, I found the problem. OPCache was enabled in the new version of MAMP Pro. Just turned it off and everything refreshes as it should. Hope that helps someone!
  13. Hi @Laikmosh, I think I have disabled all caching modules in PHP, certainly socache and file_cache_module. In terms of the cache expiry time, I'm not sure to be honest. If you have any ideas where that might be hiding I'd greatly appreciate it!
  14. I wondered if anyone has seen this and maybe has a fix? After editing Page templates are saved but code updates do not update the rendered immediately, even with a hard refresh of the page (shift+refresh). It seems to cache the page for a few mins (3-4) regardless of PW / MAMP cache settings. This applies to rendered HTML, rendered PHP variables and site_debug errors. I'm experiencing the same thing on Google Chrome Firefox. PW 3.0.184 Anyone else seen this and / or found a fix?
  15. Hi @Robin Wow, what a seriously awesome reply thanks so much. I'm going to be implementing this today. Thank you!!
×
×
  • Create New...