mr-fan Posted January 28, 2016 Share Posted January 28, 2016 Great - thank you very much! The query and if statements are never a real problem since i like to try out how it works and dig into - but sometimes i don't find the right hook or methode that i have to jump on (ProcessPageSearch::executeFor). Thank you for the hint - i will provide a complete snippet if it works. (Just some little offtopic - i place this kind of hooks until now in my admin.php - i don't get the whole difference between ready.php and admin.php...it's not really documentated where i should run/setup different little hooks/tasks better) 1 Link to comment Share on other sites More sharing options...
mr-fan Posted January 28, 2016 Share Posted January 28, 2016 Ok i tried some different setting, but without luck for the function - but i studied the ProcessPageSearch and found: // non superuser doesn't get any admin pages in their results $s .= ", has_parent!=$adminRootPage"; And now come one of PW greatest things - without fear i switched the parent (for the contentblock root) from my settings page to admin page...with kinda a 300 pages there....switched parent -> all works, editors don't get any single PageTable Pages -> all good! Best regards mr-fan 2 Link to comment Share on other sites More sharing options...
adrian Posted January 29, 2016 Share Posted January 29, 2016 Glad you found a solution by placing under admin, but if you want, here is a tested option. Place this in your admin.php - just replace the xxxx with the id of the Settings page. With this the autocomplete won't return any pages under Settings. $this->pages->addHookAfter('ProcessPageSearch::executeFor', null, 'removeBranchFromSearch'); function removeBranchFromSearch($event) { $response = $event->return; $responseArray = json_decode($response, true); $matches = $responseArray['matches']; $i=0; foreach($matches as $match) { if(wire('pages')->get($match['id'])->is("has_parent=xxxx")) { unset($matches[$i]); } $i++; } $responseArray['matches'] = $matches; $event->return = json_encode($responseArray); } 3 Link to comment Share on other sites More sharing options...
adrianmak Posted April 20, 2016 Share Posted April 20, 2016 The profields pagetable has been around in core for some time. I just started playing around it. What is the purpose of a pagetable with more than one template ? In my testing, with a pagetable configured for more than one template, as show below Two add buttons will show on the pagetable field. Could you guys give me an example or scenario to describe when to use multiple templates? Link to comment Share on other sites More sharing options...
adrian Posted April 20, 2016 Share Posted April 20, 2016 It gives your site editors the ability to add different content types "blocks" in whatever order they wish. For example, a block of text, then an image, or a video, or a two column block of text, perhaps a map - whatever you set up for them. The great thing about this, compared to letting them embed images etc within a CKEditor textarea is that you can control the output of these, rather then letting them potentially mess things up Link to comment Share on other sites More sharing options...
adrianmak Posted April 20, 2016 Share Posted April 20, 2016 Any real example? A few of screen captures are much appreciated. Link to comment Share on other sites More sharing options...
mr-fan Posted April 20, 2016 Share Posted April 20, 2016 screenshot of my PageTableExtended block list.. https://processwire.com/talk/topic/12770-does-pw-have-page-blocks/#entry116158 video and some posts below a real good example for template setup and usage: https://processwire.com/talk/topic/7459-module-pagetableextended/#entry71793 best regards mr-fan Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 20, 2016 Share Posted April 20, 2016 To stay with your example of products. You might have two different groups of products: digital ones and physical ones. A shopping cart might have a pagetable holding both types of product and displays the price, which is part of both groups. But the physical products might have addtional fields like how much products are in stock, which isn't applicable for digital products, hence the different templates. Link to comment Share on other sites More sharing options...
szabesz Posted April 20, 2016 Share Posted April 20, 2016 The profields pagetable has been around in core for some time. Did I miss something? Where is it? Link to comment Share on other sites More sharing options...
cstevensjr Posted April 20, 2016 Share Posted April 20, 2016 It's a core module that you have to install 2 Link to comment Share on other sites More sharing options...
szabesz Posted April 20, 2016 Share Posted April 20, 2016 Thanks cstevensjr! I have confused "ProFields: Page Table" with Ryan's "ProFields" package for a moment or two or three or even four Link to comment Share on other sites More sharing options...
kongondo Posted April 20, 2016 Share Posted April 20, 2016 A bit of history: PageTable is part of the ProFields. Thanks to Avoine (the sponsors) it has been made available as a free ProField. Here's a link to more info about the different ProFields, thanks to a question by @cstevensjr 3 Link to comment Share on other sites More sharing options...
adrianmak Posted April 23, 2016 Share Posted April 23, 2016 instead of using below code to create a page table row $newpage = $pages->add('basic-page', '/about/', 'address', array('title' => 'Write to us')); could i use the traditional way of creating a new page ? ie. $pt_parent = $pages->get('/page-table-parent'); $p = new Page(); $p->template = "page-table-template"; $p->parent = $pt_parent; $p->title = "page table title"; $p->body = "page table body"; $page->of(false); $page->page_table_field->add($p); Link to comment Share on other sites More sharing options...
adrian Posted April 26, 2016 Share Posted April 26, 2016 could i use the traditional way of creating a new page ? Why don't you try it and see what happens 2 Link to comment Share on other sites More sharing options...
DV-JF Posted July 7, 2017 Share Posted July 7, 2017 Copy / Clone single pagetable-pages to another page Hi is it possible to clone / copy a pagetable-page to another "parent"-page with the same pagetable field via the backend? Many Greets, Jens. Link to comment Share on other sites More sharing options...
Juergen Posted November 13, 2017 Share Posted November 13, 2017 Hello @ all, I am trying to find a solution to change the table headers via a hook. These are the hooks that can be use with a pagetable field: The fields of the pagetable can be entered in the configuration of the pagetable field inside a textarea: I guess there should be a possibility to change the labels of these fields which are used inside the table header. Changing it directly at the fields is not an option in this case. My idea was to hook like this: addHookBefore('InputfieldPageTable::render', function($event) But I have no idea at the moment how to get the labels of the fields. Does anyone has a hint how it could be done? Link to comment Share on other sites More sharing options...
Juergen Posted November 13, 2017 Share Posted November 13, 2017 I have found a solution for my posting above : https://processwire.com/talk/topic/17738-tip-how-to-change-the-table-headers-in-page-tables/ 1 Link to comment Share on other sites More sharing options...
adrian Posted November 13, 2017 Share Posted November 13, 2017 Glad you got this sorted @Juergen - just wanted to note for everyone else (which you obviously also found) that you were looking for the Inputfield, rather than Fieldtype hooks: 1 Link to comment Share on other sites More sharing options...
Juergen Posted November 13, 2017 Share Posted November 13, 2017 Thanks @adrian, unfortunately my solution does not work if the page table is updated via Ajax after a child page is saved in the modal. I have tried to use the code inside init.php instead of ready.php but I cannot solve this problem. Do you have an idea? Link to comment Share on other sites More sharing options...
PWaddict Posted April 10, 2018 Share Posted April 10, 2018 On 3/12/2015 at 2:40 AM, adrian said: Here is something I hacked together quickly for automatically adding new child pages to the pagetable field. This is only if you are using the page as the parent. It also handles deletion of items if they are trashed externally. I also disabled the internal check for orphans - because they have been automatically added already, there is no need for the "Children were found that may be added to this table. Check the box next to any you would like to add." option. I seems to be working great here, but please test carefully!! Add this to your admin.php file: wire()->addHookBefore('InputfieldPageTable::render', function($event) { $pp = wire('pages')->get(wire('input')->get->id); $ptf = $event->object; //remove pages from pagetable field if they were externally trashed foreach($pp->{$ptf->name} as $item) { if($item->is(Page::statusTrash)) $pp->{$ptf->name}->remove($item); } //add pages to pagetable field if they were created externally foreach($pp->children as $child) { if(!$ptf->has($child->id)) { $pp->{$ptf->name}->add($child); $pp->of(false); $pp->save($ptf->name); } } //reset orphans property so that we don't get a message asking to add new pages that are now already automatically added $ptf->setOrphans(new pageArray()); }); Instead of adding this to admin.php, I've added it to init.php. It's ok right? 1 Link to comment Share on other sites More sharing options...
adrian Posted April 10, 2018 Share Posted April 10, 2018 15 hours ago, PWaddict said: Instead of adding this to admin.php, I've added it to init.php. It's ok right? Yeah - I don't think init.php and ready.php existed when I wrote this. I guess the only advantage to admin.php is that it is only called in the backend, whereas init.php and ready.php are called in frontend as well. It won't make any significant impact on performance though, so whatever works for you. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now