Gideon So Posted November 5, 2014 Share Posted November 5, 2014 Hi all, Do anyone can explain Page Table fieldtype? I have tried a few times but still have no idea about it. If anyone can show me the way, I am very grateful. Gideon So Link to comment Share on other sites More sharing options...
kongondo Posted November 5, 2014 Share Posted November 5, 2014 Hi Gideon So, Welcome to ProcessWire and the forums. Have a read here: https://processwire.com/talk/topic/6417-processwire-profields-table/?p=63119 2 Link to comment Share on other sites More sharing options...
Gideon So Posted November 6, 2014 Author Share Posted November 6, 2014 Hi Kongondo, Thanks for the reply and I read them all before I post this. I still don't get an idea on the pagetable field. I tried it on my testing site. Is it normal that everytime I add a table, a new page is added and the content in the child page shown on the pageTable feild. Is it the way it works?? If someone can write an tutorial or a example would be greate to us. Thanks. Gideon Link to comment Share on other sites More sharing options...
Valery Posted November 21, 2014 Share Posted November 21, 2014 Hello, PageTable is described as a leaner way to enter large amount of repeatable data into the admin backend, possibly with different sets of fields (think different templates). The main advantages compared to the Repeater are: 1. PageTable can save new pages where you tell it to. Repeaters are saved deep down the Admin pages and are given cryptic names. 2. One PageTable field can make use of several different templates. Repeaters play according to the "One repeater = one template" rule (roughly put). PageTable is a PageArray, so relevant methods are applicable. For example, here is how to add and remove items from a PageTable field using the PW API: // create a new page // IMPORTANT: your PageTable field must be configured to use template 'basic-page' in the field Setup tab $newpage = $pages->add('basic-page', '/about/', 'address', array('title' => 'Write to us')); $page->of(false); // add the newly created page to 'pt' which is a PageTable field $page->pt->add($newpage); $page->save(); Here is how to remove the first item from a PageTable field: $page->of(false); // 'pt' is a field of type PageTable $page->pt->get(0)->delete(); $page->save(); That's a quick overview of this new field type. Give it a bit of your attention, it's quite promising. Cheers, Valery. 8 Link to comment Share on other sites More sharing options...
Ole Posted November 24, 2014 Share Posted November 24, 2014 I tried it on my testing site. Is it normal that everytime I add a table, a new page is added and the content in the child page shown on the pageTable feild. Is it the way it works?? Short answer to your question: Yes. That's the way how it works. Everything else is well explained in the Forum post, I think. Link to comment Share on other sites More sharing options...
Lance O. Posted November 24, 2014 Share Posted November 24, 2014 I was going to start a new post but will piggyback on this one since my questions are related. As Ryan has stated previously: "PageTable lets you choose where [pages] should live, whether as children of the page being edited, or as children of some other parent page you designate." Can someone elaborate on the pros and cons of storing pages as children of the page being edited vs. children of some other page? I also understand that no matter the location of the child pages, additional child pages can only be added by using the PageTable field that has been set up. Are there some cases where it is better to hide stored pages under some other page to prevent confusion (from the client) when editing? It would also be helpful to know what types of data are most appropriate for PageTables. For instance, instead of using a repeater field, would the use of PageTables be more appropriate for PDF files that need to include additional fields, such as description or category? Link to comment Share on other sites More sharing options...
Macrura Posted November 25, 2014 Share Posted November 25, 2014 @Lance - I think you'll find that for the most part it is easiest to keep the pagetable pages as children of the page, but it will also depend a lot on your structure, and whether that page has children already, in which case put them somewhere else.. some examples of where i've use pagetables, and i think it will make sense: | Page | PageTable Children | |-----------|--------------------| | Album | Tracks | | Slide | Captions | | Portfolio | Images | | Vignettes | Vignette | i think if you use the reno theme and also lister pro, it actually won't matter that much where you put them; but in a lot of cases having them as children keeps things tidy and you can always get the relation of a pagetable item by calling it's parent. and you can add pages not through the page table, and it will pick them up and ask you if you want to add them. For PDFs, depending on the amount on one page, i might still consider good old repeaters 2 Link to comment Share on other sites More sharing options...
Lance O. Posted November 25, 2014 Share Posted November 25, 2014 @Macrura Thanks for your response. Your examples help me understand when to use PageTables. You mentioned that "you can add pages not through the page table, and it will pick them up and ask you if you want to add them." What are you referring to here? Link to comment Share on other sites More sharing options...
Macrura Posted November 25, 2014 Share Posted November 25, 2014 @Lance If I recall correctly, there is a setting for the page table field that will enable it to show items not created by the page table and show the option to add them. You would see that below the page table. Link to comment Share on other sites More sharing options...
Lance O. Posted November 25, 2014 Share Posted November 25, 2014 Ah, I see it now after a bit of testing. Thanks for the insight and quick response! Link to comment Share on other sites More sharing options...
Lance O. Posted November 25, 2014 Share Posted November 25, 2014 I just discovered that if you create child pages of a parent page, then decide to add a PageTable field that includes template of the existing child pages, those child pages won't be available to add to the PageTable field on the parent page. In other words, if you are going to use a PageTable field, it appears that you'll need to make sure you create this field before you start adding child pages. Link to comment Share on other sites More sharing options...
Macrura Posted November 25, 2014 Share Posted November 25, 2014 yeah but a little api magic can cure that.. open up your tools or api playground and: $pp = $pages->get(1234); // page you're adding the children to the page table foreach($pp->children as $child) { $pp->page_table_field->add($child); } 8 Link to comment Share on other sites More sharing options...
Lance O. Posted November 25, 2014 Share Posted November 25, 2014 Beautiful! Link to comment Share on other sites More sharing options...
Valery Posted November 27, 2014 Share Posted November 27, 2014 Excuse me for interrupting, but what PW version did you find this option for a PageTable field? I am using 2.5.3 and I see nothing like an "add an existing page" toggle for a PageTable field. Link to comment Share on other sites More sharing options...
Michael Murphy Posted December 3, 2014 Share Posted December 3, 2014 Hi @Valery, I have also been looking for this "add an existing page" option for the PageTable. I have yet to find it, but after reading this thread, maybe it is only visible when you have the PageTable pages stored as children of the parent page. I am always storing my PageTable pages in a separate hidden folder. Would be nice to have this as an alternative way to add or import pages into a PageTable. Was also wondering if it would be possible to have one page in multiple PageTable fields (like a reusable common page). Otherwise I am really liking this PageTable field and finding it very useful in all my recent client projects. It allows for some really interesting design and layout possibilities for mixed media and content heavy sites. Link to comment Share on other sites More sharing options...
Macrura Posted December 4, 2014 Share Posted December 4, 2014 pretty sure that this only works for children of the page (showing new pages that can be added)... but will need to test it to confirm... Was also wondering if it would be possible to have one page in multiple PageTable fields (like a reusable common page). @Michael Murphy - this would basically be equivalent to my module in progress (currently an admin custom pages drop in), which would allow you to use regular page selects, but have the ability to access/edit them in a modal by clicking on the title.. you wouldn't be able to mix and match these with pagetables; i think of page table pages as pages that have to directly relate to to the page and can't be altered by any other page. https://processwire.com/talk/topic/7588-admin-custom-files/?p=81866 there are other ways you could achieve various functionality - for example write a module that clones the pages in a page select to new page table pages where you could then have contextual access to those new pages without the risk of affecting some other place that page is being used; 1 Link to comment Share on other sites More sharing options...
Valery Posted December 4, 2014 Share Posted December 4, 2014 Hello Michael, In response to your earlier post: I've tried storing PageTable pages directly under the parent but it didn't work (for me, at least). However, the idea behind trying to use existing pages in a PageTable field escapes me. Why not use Page fields with PageListSelect+ instead? For instance, here is a screenshot of mock-up of a color chooser for a webshop item. 1 Link to comment Share on other sites More sharing options...
Michael Murphy Posted December 4, 2014 Share Posted December 4, 2014 @Macrura thanks I will have a look at your module. @Valery this is a good idea, thanks. I will probably just add a Page field (with Page Auto Complete) to the template which will allow the editors to easily choose any other page. Link to comment Share on other sites More sharing options...
Gideon So Posted December 6, 2014 Author Share Posted December 6, 2014 Hi all, Thanks guys for all your precious input. I got an solid idea now. Gideon Link to comment Share on other sites More sharing options...
alexm Posted December 29, 2014 Share Posted December 29, 2014 Hey man, Sorry to bring this up again but based on the below quote by @Macrura I have tried hooking into the api with the below code to add some pages but it doesn't seem to work for me. my PageTable field is called projects so have replaced page_table_field and used the correct parent ID and have tried calling this from say, the home page but it doesn't seem to work. Any thoughts, Cheers yeah but a little api magic can cure that.. open up your tools or api playground and: $pp = $pages->get(1234); // page you're adding the children to the page table foreach($pp->children as $child) { $pp->page_table_field->add($child); } Link to comment Share on other sites More sharing options...
Macrura Posted December 29, 2014 Share Posted December 29, 2014 Did you save the field? After adding the items? $pp = $pages->get(1234); // page you're adding the children to the page table foreach($pp->children as $child) { $pp->page_table_field->add($child); } $pp->of(false); $pp->save('page_table_field'); 1 Link to comment Share on other sites More sharing options...
alexm Posted December 30, 2014 Share Posted December 30, 2014 No I hadn't. Whoops... My bad on that. However, I have added the two last lines but still no joy. seems bit odd to me Link to comment Share on other sites More sharing options...
Macrura Posted December 30, 2014 Share Posted December 30, 2014 How about saving the page instead of the field? Link to comment Share on other sites More sharing options...
alexm Posted December 30, 2014 Share Posted December 30, 2014 Hmmm, nope. Bizarre. Thanks for your patience @Macrura ! Link to comment Share on other sites More sharing options...
adrian Posted December 31, 2014 Share Posted December 31, 2014 I just tested that code and it is working fine here. Have you checked that the Add New button actually works for the page table field. Make sure there are no errors like template not allowed or anything else wrong with the page table config setup. Do you have debug mode turned on? 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