-
Posts
250 -
Joined
-
Last visited
Everything posted by prestoav
-
[SOLVED] Page Field Select From Grand Parent of Page?
prestoav replied to prestoav's topic in General Support
@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! -
[SOLVED] Page Field Select From Grand Parent of Page?
prestoav replied to prestoav's topic in General Support
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. -
[SOLVED] Page Field Select From Grand Parent of Page?
prestoav replied to prestoav's topic in General Support
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! -
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!
-
$session is set but empty - $_SESSION has data?
prestoav replied to prestoav's topic in General Support
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. -
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!
-
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.
-
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.
-
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!
-
Moving Image Files Between File Fields On the Same Page
prestoav replied to prestoav's topic in General Support
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. -
Moving Image Files Between File Fields On the Same Page
prestoav replied to prestoav's topic in General Support
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! -
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?
-
Moving Image Files Between File Fields On the Same Page
prestoav replied to prestoav's topic in General Support
Hi @Robin Wow, what a seriously awesome reply thanks so much. I'm going to be implementing this today. Thank you!! -
I am re-working an advert editor on a marketplace site and one of the most requested features is to be able to reorder the images that have been uploaded. To do this I need to be able to move existing images between separate page fields (let's call them image_1, image-_, image_3 etc.). The fields are all setup to have only one image each in the field setup. So far I have the functionality sorted to allow advert owners to delete images or upload replacement images for each field if needed and that all works fine. I also have an edit form that tracks the images as they are dragged around in JQuery UI so that, when the edit form is submitted, they post-processing can see the original field the image was in and the intended field that the image needs to move to as a result of the reordering. I'm now stumped as to how to best move the actual files around so they show in the right order, both in the live advert and in the edit form if it's edited again. Has anyone found a good way to do this? The stumbling block is that each field can only tae one file at a time so it feels like I need to move all the files to be moved into a temporary location then move them back into the right, new spots. Any suggestions very much appreciated!
-
Works a treat, thank you ?
-
Superb, thanks I'll try that out!
-
I'll certainly look into that.
-
@Robin S Thanks for getting back to me. Your initial suggestion does work on live sites in a domain root but, sadly, not in a development environment where different sites are housed on sub folders. For example, if the site is at www.mydomain.com then the resulting link is www.mydomain.com/admin/page/edit/?id=1016 and this works from all admin pages. However, if the site is at localhost:8888/dev_site_1/ then the link created is localhost:8888/admin/page/edit/?id=1016 (i.e. the 'dev_site_1' is missing) and the resulting link does't work. I'll investigate the hook method of course but many devs might find this useful to work in their framework sites. Thanks again for the good work.
-
Nice work @Robin S! One Issue I've come across that I'd be really keen on a solution for is to support $config->urls in the URL field. For example, I have a 'Site Settings' page in all my sites where the client can edit the global company details like phone, email, address etc. I'd like to add a link in the top admin bar to this page so it's easy to find (some sites have a lot pf pages in the tree)! I can do it once the site is launched with an absolute URL but I'm struggling with a relative URL that I can add to my Framework site. This is because the correct relative link depends on the page the 'Settings Page' was accessed from: This would work from another edit page: ../../admin/page/edit/?id=1016 However, it would need to be this from the page tree: ../admin/page/edit/?id=1016 One fix would be to support $config->urls in {} e.g. {$urls->admin}page/edit/?id=1016 As per these docs: https://processwire.com/api/ref/paths/ Hope this helps and thanks for the module!
-
Hi folks, I've set up a field to link to an other internal page and with a Input Field Type of Page List Select. All work well until you want to remove a selection altogether. Adding a page in from the list or changing it is fine but I can't find a way for the editor (or Superuser) to remove a selection once it's made. See screen grab attached. Clicking on 'Change' shows the list of pages to choose from but no way of removing any selection to leave it blank. I ended up deleting that line from the database manually but obviously that's not a solution. Anyone found out how an editor can do this? PW 3.0.165 Thanks!
-
[Solved] Admin 'View' links removing port nos?
prestoav replied to prestoav's topic in General Support
Hi there. Yup, you guessed it. Thank you, I can't believe after all this time I missed that!