alexcapes
Members-
Posts
120 -
Joined
-
Last visited
Everything posted by alexcapes
-
Getting PageTable containing page values
alexcapes replied to alexcapes's topic in Module/Plugin Development
Ah ha! Yes it's working now! Thank you My final challenge on this is getting a couple of field values from the containing page of the quote into the custom page label format of 'quotes_featured'. I'm going to look at either RuntimeMarkup or FieldtypeReference for that challenge. -
Getting PageTable containing page values
alexcapes replied to alexcapes's topic in Module/Plugin Development
Option 1 is unfortunately not viable as I need the client to be able to reorder the featured quotes. Option 2 this sounds like it could be perfect but I've tried doing exactly as you said and I'm getting errors. If I try to save the Quote page with the checkbox ticked it timesout with the error: Error: Maximum execution time of 30 seconds exceeded (line 1431 of /Users/alexcapes/Freelance-work/canongate/01_prototype/wire/core/Page.php) If I try to save the 'featured_quotes' page field on the homepage I get the following: Session: Method NullPage::add does not exist or is not callable in this context -
Getting PageTable containing page values
alexcapes replied to alexcapes's topic in Module/Plugin Development
Could this help with the issue I'm having with updating on updating PageTable after saving on the modal? -
Getting PageTable containing page values
alexcapes replied to alexcapes's topic in Module/Plugin Development
Ah yeah I think I over complicated the issue (which I find quite easy to do with PageTable fields...!). -
Hi, I've created a simple module that does the following: Checks if a checkbox is ticked ('media_wall_quote_hero') on a page using the template 'media_wall_quote'. If that checkbox is ticked, it adds that page to a PageTable field ('quotes_hero') located on the 'home' template. If it's not checked and the page is in the PageTable field it is removed. It all works correctly when checking/unchecking the box on pages using the 'media_wall_quote' template in admin. However, if I edit the pages in the PageTable field itself on the homepage in admin, when I save the modal, the PageTable field is not updated. Strangely if I uncheck it (ie. when it should be removed) the PageTable field says 'item added'. Is there a way I can hook into the PageTable field when the modal is saved and update it so if I check/uncheck the box it does the correct action? public function init() { $this->pages->addHookAfter('save', $this, 'AddRemoveHeroQuotes'); } public function AddRemoveHeroQuotes($event) { $page = $event->arguments(0); if($page->template == 'media_wall_quote') { $home = wire('pages')->get(1); $home->of(false); $work_page = wire('pages')->get("template=work, media_wall_work=$page"); // If this quote is a (published) hero quote add it to the pagetable field if($page->media_wall_quote_hero == 1 && !$page->is(Page::statusUnpublished)) { if(!$home->quotes_hero->has($page)) { $home->quotes_hero->add($page); } } // If this quote is a not a hero quote or is unpublished remove if from the pagetable field elseif($page->template == 'media_wall_quote' && $page->media_wall_quote_hero == 0 || $page->template == 'media_wall_quote' && $page->is(Page::statusUnpublished)) { if($home->quotes_hero->has($page)) { $home->quotes_hero->remove($page); $this->message('removed'); } } $home->save('quotes_hero'); } }
-
Getting PageTable containing page values
alexcapes replied to alexcapes's topic in Module/Plugin Development
Basically the media_wall_work_ref was a reference number that relates to the containing page. I was hoping that if this was saved to the PageTable field, then I could make a two way connection between the page and the PageTable field. Having a look at it, I've rethought my use of the PageTable field because these hooks won't work. -
Wonderful, thank you @Robin S - installed on 3.0.39 and all seems to be working perfectly. This kind of extra control over PageTable fields is something I find more need of the more I use this type of field.
-
Hi, I have a PageTable field that contains fields that I need populate with values from fields in the containing page when the page is saved. I've tried to do this with a module but I can only get the fields to populate when it's saved for a second time (or saved after publishing), which is not ideal behaviour. Here's my code: public function init() { $this->pages->addHookBefore('save', $this, 'AddWorkReferenceQuote'); } public function AddWorkReferenceQuote($event) { $page = $event->arguments(0); if($page->template == 'media_wall_quote') { if($page->id) { $work_page = wire('pages')->get("template=work, media_wall_work=$page"); $page->media_wall_work_ref = $work_page->work_ref_id; I think the issue is: $work_page = wire('pages')->get("template=work, media_wall_work=$page"); Which doesn't returning the PageTable containing page on first save/publish. I've tried changing the hook to addHookAfter but this has no effect and stops it from working altogether. Anyone have an idea how I can access the containing page of a PageTable page before save?
-
Limit usage of template in PageTable field
alexcapes replied to alexcapes's topic in API & Templates
@Robin S How easy would it be to turn the options into a repeater? I've found this module so useful I'm in need to use it across multiple PageTable fields. -
Limit usage of template in PageTable field
alexcapes replied to alexcapes's topic in API & Templates
Ahh I'm not sure what was not working for me with the template.label but just installed LimitPageTable v0.0.3 and seems to be working perfectly for me now. Thank you Robin! -
Set order of pages in PageTable field via API
alexcapes replied to alexcapes's topic in API & Templates
Thanks for this - I'm going to experiment more with the PageArray and methods like insertAfter(). Unfortunately I do need to delete + recreate the pages. I'm dealing with large XML data files, which are updating existing pages in PW. Not only does the XML update fields but it will sometimes not include fields which is seen as the equivalent of deleting those fields entirely. It gets complicated and messy and was agreed that deleting and recreating the pages was all round cleaner way of doing things. Not ideal I know but it works for this project. -
Set order of pages in PageTable field via API
alexcapes replied to alexcapes's topic in API & Templates
Should this output the sort #? Doesn't seem to output anything for me... $edition->sort; -
Set order of pages in PageTable field via API
alexcapes replied to alexcapes's topic in API & Templates
I've actually created a working solution (which I'm sure can be improved upon but it works for now). I've made a simple module that populates a field ('edition_sort') on each PageTable page with it's order number: $i = 1; $editions = $page->editions; foreach($editions as $edition) { $edition->of(false); $edition->edition_sort = $i; $edition->save(); $i++; } I can then get this field ('edition_sort') value from the page being deleted and add it to the newly created page, then sort the PageTable by the field. It all works but I'm sure there's a much neater way of doing it! -
Set order of pages in PageTable field via API
alexcapes replied to alexcapes's topic in API & Templates
Would you mind expanding on this Adrian? How would I set the sort property of each item in the PageTable field? -
I have a PageTable field that is updated via a custom module. Pages are updated by deleting them then re-adding but crucially need be re-added in the same order in the PageTable field. If I re-add pages, they go to the bottom of the field (it's a manual drag n drop setting). Is there a way to re-add where the page was previously? Or at the very least I need to maintain the first page in the field. It has a checkbox ticked if it's first so the re-added page could use that to test whether it needs to go first. I just don't know how to set the order of pages in a PageTable field via the api. Any help here much appreciated.
-
Limit usage of template in PageTable field
alexcapes replied to alexcapes's topic in API & Templates
1. Changing to use template.label as you describe seems to stop the module from working. Does any other code need updating for this to work? 2. When I was saving the PageTable page in the overlay I would need to save the page with the PageTable field in it before the button would disappear. However v0.0.2 seems to fix this - I see the button disappear when I click off the overlay. -
Limit usage of template in PageTable field
alexcapes replied to alexcapes's topic in API & Templates
Wonderful! Thank you Robin. Working for me on v3.0.39 I'll dig through the code as there's some updates I'd like to make... Display template label instead of name in admin (mainly for readability for client) Disable button on saving the page in the PageTable field rather than the parent page -
Hi, I have a PageTable field where one template type should only be used once per PageTable as otherwise it will break the lazy-loading pagination on the front-end. Is there a way to limit the number of times a template is used? I think I basically need to create a module that... Checks children of specific template for 'date_listing' template If one child is using the template, disable this template from being available for new pages under that parent Disable the button on the PageTable field for creating a new page with 'date_listing' template (1) is pretty straightforward but (2) and (3) have me puzzled - is it possible to disable template use dynamically?
-
How to get PageTable pages when not published
alexcapes replied to alexcapes's topic in API & Templates
Just to note this works but does not seem to work outputting image fields.- 9 replies
-
- pagetable
- unpublished
-
(and 1 more)
Tagged with:
-
How to get PageTable pages when not published
alexcapes replied to alexcapes's topic in API & Templates
It's a valid point - I think I may just have to rethink the workflow and require that editor publishes at least one PageTable page to be able to view the parent page.- 9 replies
-
- pagetable
- unpublished
-
(and 1 more)
Tagged with:
-
How to get PageTable pages when not published
alexcapes replied to alexcapes's topic in API & Templates
It's just not outputting anything for me. echo $page->editions[0]->id; This outputs nothing. However if I publish one PageTable page, it correctly echos the ID.- 9 replies
-
- pagetable
- unpublished
-
(and 1 more)
Tagged with:
-
I have a PageTable field (editions) that I need to access the top page even if the page is unpublished: $page->editions[0]->id This throws up an error when the top page is unpublished, however works fine when it's published. I know I can't access the pages as children because the PageTable order differs from the child order, and I need the top page as it is in the PageTable field. Any ideas how I may be able to do this?
- 9 replies
-
- pagetable
- unpublished
-
(and 1 more)
Tagged with:
-
@ryan I'm looking at using autolinks on a project for a book publisher. They will have hundreds of titles and wondered whether it's possible for the following: Import lists of terms to be autolinked or use a textfile? Specifically on this site it would be book titles and it's not practically to manually add these to the module Make the terms case senstive? Thanks!
-
Front-end editing reinitialize JS after save
alexcapes replied to alexcapes's topic in API & Templates
Thanks Ryan. Adding: t.trigger('pwreloaded'); After 352 and using this in my JS worked for me... $(document).on('pw-modal-closed', '.pw-edit-modal', function() { // my code goes here }); -
Front-end editing reinitialize JS after save
alexcapes replied to alexcapes's topic in API & Templates
This now works on editable text fields, only when a change to the text has been made: $(document).on('pwreloaded', '.pw-edit .pw-edit-copy', function() { console.log("reloaded"); }); I'm looking at getting it working on a repeater field, which is the modal edit view. I've tried using: $(document).on('pwreloaded', '.pw-edit-modal', function() { console.log("reloaded"); }); But no luck with it yet.