artfulrobot Posted September 19, 2022 Share Posted September 19, 2022 On 5/20/2014 at 11:05 AM, apeisa said: Nope, not yet. I am pretty sure there will be documentation before 2.5 is released. Did this ever happen? I can't find any PageTable documentation for all my searching! It seems odd, the docs are so great, generally. (I'm specifically looking for how to create a page with several pagetable field values programmatically). 2 Link to comment Share on other sites More sharing options...
gornycreative Posted March 1, 2023 Share Posted March 1, 2023 You know, I was looking into this as well for the opposite reason in that I have always used RepeaterMatrix to build up customizable content stacks but I found old posts talking about how PageTable was more efficient for this than Repeaters and so I've been sleuthing and unfortunately the road ends here? Maybe someone who has been here longer can chime in? Link to comment Share on other sites More sharing options...
gebeer Posted March 2, 2023 Share Posted March 2, 2023 On 9/19/2022 at 10:09 PM, artfulrobot said: (I'm specifically looking for how to create a page with several pagetable field values programmatically). Behind the scenes entries in a PageTable field are just regular pages in a regular PageArray. Lets say you have a field "pagetable" and it is configured to use template "blog-post" for items. You can create a new page with new items in the pagetable field like this: // create page that holds pagetable items $p = new Page(); $p->template = 'basic-page'; $p->parent = '/foo/'; $p->title = "Bar"; $p->save(); // get parent id for pagetable items from field config $parentID = $p->getField('pagetable')->parent_id; // create item page for field pagetable $item = new Page(); $item->template = 'blog-post'; $item->parent = $parentID; $item->title = "Item Foo"; $item->save(); // add item page to pagetable field $p->pagetable->add($item); $p->save('pagetable'); Since the value of $p->pagetable is a PageArray, you can find and manipulate the pagetable items with methods from Pages, PageArray and WireArray. To remove a specific item: $item = $p->pagetable->get('title="Item Foo"'); $p->of(false); $p->pagetable->remove($item); $p->save('pagetable'); You can also use WireArray manipulation methods insertBefore(), insertAfter(), append(), prepend() to add items in a specific order. 3 Link to comment Share on other sites More sharing options...
Jozsef Posted March 22, 2023 Share Posted March 22, 2023 I'm having trouble displaying a pagetable field in the same order as it appears on the page edit screen. The child pages are hidden so I use $page->getUnformatted("field") to get the array of pages but a foreach loop outputs them in completely random order. When I try sort("sort") it then appears in the order of the child pages in the page tree so that "sort" refers to the order from the Pages table. I never had trouble with this in earlier versions, this random order appeared in the last two websites I'm developing. Is there a way to access the internal sort of the actual pagetable field as per screenshot? Link to comment Share on other sites More sharing options...
CrazyAppel Posted May 28 Share Posted May 28 In file FieldtypeTable.module on line: 1355 code should be: $v = explode(',', $v ?? ''); // old code: $v = explode(',', $v ); php +8.1 otherwise gives an error: PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in... Link to comment Share on other sites More sharing options...
jonassalen Posted September 23 Share Posted September 23 I need some help. I'm using this great module for displaying data in a table, but on mobile I want to display each COLUMN in a different way. Any easy way to get an array of the data PER COLUMN? Thanks in advance. 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