alexm Posted December 31, 2014 Share Posted December 31, 2014 I can add new pages from the parent using the Add New button with no errors. I have checked the inputfield set up and there are no errors there too. I have debug enabled, but I can't see any errors. I am surely missing something simple... Link to comment Share on other sites More sharing options...
thistimj Posted January 18, 2015 Share Posted January 18, 2015 I am having a problem with Page Tables. I am using 2.5.14 dev on my local WAMP install, but I remember having similar issues with the latest master version. I set up my templates: entry-image and entry-text; these are what I want to control with my Page Table field called entry_sections. I add entry_sections to my work-entry template and I see the "Add entry-image" and "Add entry-text" buttons at the bottom of the Page Table field. When I click add entry-image, the modal window says "entry-image" as it should. But, when I click the button to add entry-text, the modal window says "entry-image". As a test, I went to the entry_sections field and removed the entry-image template. When I go back to the page, it still only wants to add "entry-image" even though the only option is to add entry-text. Ideas anyone?? Thanks. Link to comment Share on other sites More sharing options...
thistimj Posted January 19, 2015 Share Posted January 19, 2015 I figured out my issue. I had set my work-entry template to only allow pages with entry-image as children. I had to add entry-text as an allowed child template. D'oh! Maybe this will help someone in the future. Link to comment Share on other sites More sharing options...
hwmaier Posted February 3, 2015 Share Posted February 3, 2015 Did anyone figure out whether it is possible to add existing pages to the PageTable when using a parent for item storage? Link to comment Share on other sites More sharing options...
Jan Romero Posted February 3, 2015 Share Posted February 3, 2015 Sure it’s possible. I’d love to see a more page-field-like PageTable, actually. Here is a (really, seriously) half-assed module that lets you add a page to a PageTable field. Be aware, when you remove your page from the field, it will trash the entire page just like the standard PageTable does. Do NOT use this anywhere but in a testing environment. It also has a hard coded template that you shoult probably change to whatever your PageTable accepts. $this->addHookAfter('InputfieldPageTable::render', $this, 'PageTableRender'); public function PageTableRender($event) { $pageTable = $event->object; $out = "<select name='{$pageTable->name}_addcustom'>"; $pages = $this->pages->find('template=PAGETABLETEMPLATE'); //change this foreach ($pages as $p) { $out .= "<option value='{$p->id}'>{$p->title}</option>"; } $out .= '</select>'; $out .= "<script> $(document).ready(function(){ $('select[name=\"{$pageTable->name}_addcustom\"]').change(addPage); function addPage() { var input = $('input[name=\"{$pageTable->name}\"]'); var container = input.siblings('.InputfieldPageTableContainer'); var dataurl = container.attr('data-url'); var pageid = $('select[name=\"{$pageTable->name}_addcustom\"]').val(); var ajaxURL = dataurl + '&InputfieldPageTableAdd=' + pageid; $.get(ajaxURL, function(data){ container.html(data); container.effect('highlight', 1000); }); alert('wtf did you do'); } }); </script>"; $event->return .= $out; } As you can see, the heavy lifting in the PageTable field is done via Ajax. Maybe it’s a starting point. I really need to go to bed 2 Link to comment Share on other sites More sharing options...
Alfred Posted March 11, 2015 Share Posted March 11, 2015 Is there a way to prevent deleting a PageTable item for a user. It would be nice if it could be set on a user / template base. I know a hook is the way to do it but setting this up myself is unfortunately not within my reach. Any help would be appreciated Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 Items can only be deleted from a pagetable if the user has the rights to delete the page, which the pagetable links to. This can be set in the corresponding templates' settings. Link to comment Share on other sites More sharing options...
Alfred Posted March 11, 2015 Share Posted March 11, 2015 Thank for your quick reply. In the template "acces tab" I cannot find the option to prevent a user to delete a page. I searched all the other tabs but could not find it. But in my case the editor does not have the right to delete pages (role setting) so he should not be able to delete the pagetabel item. Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 11, 2015 Share Posted March 11, 2015 Oh yeah, I don't recall that access form correctly everytime. One would have to use hooks to limit a user from deleting only certain pages. Link to comment Share on other sites More sharing options...
adrian Posted March 12, 2015 Share Posted March 12, 2015 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()); }); 13 1 Link to comment Share on other sites More sharing options...
thetuningspoon Posted June 17, 2015 Share Posted June 17, 2015 Perfect! Thank you so much for this, adrian!! ( also, I think this should be the core functionality ) 3 Link to comment Share on other sites More sharing options...
thetuningspoon Posted July 2, 2015 Share Posted July 2, 2015 I found a bug: if(!$ptf->has($child->id)) { $pp->{$ptf->name}->add($child); $pp->of(false); $pp->save($ptf->name); } Should be: if(!$pp->{$ptf->name}->has($child)) { $pp->{$ptf->name}->add($child); $pp->of(false); $pp->save($ptf->name); } It was re-writing the PageTable items every time, which made it impossible to reorder items. 3 Link to comment Share on other sites More sharing options...
naldrocks98 Posted July 8, 2015 Share Posted July 8, 2015 nice post...great use Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 8, 2015 Share Posted July 8, 2015 There seems to be something wrong in either your code (besides the posted snippet) or potentially 3rd party modules. You seem to be adding the page to the page table just right. Link to comment Share on other sites More sharing options...
mr-fan Posted August 13, 2015 Share Posted August 13, 2015 Just a shot question... How can i get the first item of a PageTable field with a specific template pages are stored central hidden admin page...and i nedd this in a function to get the first text field of a multiple contenttype PageTable example: PageTable field = pt_contents -> i wanna get access to the fieldentries of the first item of pt_contents with the template part_text? i'm little stucked... Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 13, 2015 Share Posted August 13, 2015 // Should be automatically sorted like the page-table field. $page->pt_contents->get("template=part_text"); 2 Link to comment Share on other sites More sharing options...
mr-fan Posted August 13, 2015 Share Posted August 13, 2015 Thank you very much - works great - always getting an error with ->first() or something else...since it is not needed and with get the first item with given selector is there! I'm working on a kind of contentbuilder PageTable that works as replacement for the main body field with a stripped CKE and own templates for the contentblocks...and i used to get some kind of teaser so i was searching for the first text element in the different blocks! Thanks again - regards mr-fan Link to comment Share on other sites More sharing options...
ottogal Posted December 18, 2015 Share Posted December 18, 2015 Just a hint: Adrian's addition to admin.php (see post #35 in this thread) - while working well in PW 2.7.0 - is causing an error in PW 3.02: The class pageArray() is not found. Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 18, 2015 Share Posted December 18, 2015 PW 3 does use namespaces, so either it's an issue with the compiler, so please try using correct case ("PageArray()") or the file is not supposed to be compiled and therefore does need the namespace "ProcessWire/PageArray()". Link to comment Share on other sites More sharing options...
mr-fan Posted January 28, 2016 Share Posted January 28, 2016 One Question on PW Link Dialog - How could i prevent that PageTable Items like part_text, part_image ...get listed in this dialog. I've a kind of blockbuilder running with PageTable and have the Pages under a hidden Parent in the tree. But pages are listet. Could i hook in the link dialog and exclude the PageTable Templates? Best Regards mr-fan Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 28, 2016 Share Posted January 28, 2016 Are you talking about the CKEditor link editor? Link to comment Share on other sites More sharing options...
mr-fan Posted January 28, 2016 Share Posted January 28, 2016 yes - i know this is a bit tricky there.. on a page field where i link "see also" kind pages i have full control about the ouput. But on the PW Link plugin all pages are there - pagetable pages, too... The search suggestion should don't show something like this: Term: >about< Autocomplete: /about/something/ /about/ /contentblocks/about-us/ while contentblocks is a hidden parent page for the contentblockpages - that for shure not hidden. I've searched the forum - i had some experience in changing the PWImage plugin to bind it to a specific parent page (for central image handling) but with help from adrian. Can you give me a hint where to hook/start right? Best regards mr-fan Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 28, 2016 Share Posted January 28, 2016 The autocomplete field is a bit of a beast on it's own because it's internally using processwire's search (imho. in a lack of other ajax api endpoints) I'm not sure how well this thing can be configured. But it should certainly not reveal hidden pages (to unauthorized users), which I would consider a bug. Link to comment Share on other sites More sharing options...
mr-fan Posted January 28, 2016 Share Posted January 28, 2016 I was afraid that... Configuration for now is a have page /contentblocks/ as hidden parent with no edit rights to the editors group /contentblocks/xxxxx/ childpages with edit/view rights for editors The parent is under a normal /settings/ page in the pagetree. Would it be better if the blocks are under the admin branch of the tree - may this is my issue? Link to comment Share on other sites More sharing options...
adrian Posted January 28, 2016 Share Posted January 28, 2016 The search suggestion should don't show something like this: @mr-fan, This actually should be quite simple. Add an after hook on: ProcessPageSearch::executeFor and call this method: public function removeHiddenFromSearch($event) { $response = $event->return; $responseArray = json_decode($response, true); $matches = $responseArray['matches']; $i=0; foreach($matches as $match) { if($this->pages->get($match['id'])->isHidden()) { unset($matches[$i]); } $i++; } $responseArray['matches'] = $matches; $event->return = json_encode($responseArray); } This will remove all hidden pages from the results, but I get the feeling the pages themselves are not actually hidden, just the "Settings" parent. Is that correct? In that case change "isHidden()" to check if the page is a child of the "Settings" parent - I'll let you figure that out 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