Jump to content

PageTable templates (docs?)


suntrop
 Share

Recommended Posts

I've got a PageTable field and added several templates (intro, gallery, text, etc.). But how do I get those templates rendered? I can't find any docs and feel like revolving from the forum to the store.

Anyhow. Perhaps someone can help. I have my basic-page.php with the PageTable field and its (sub-)pages. For example the gallery. I created the gallery.php file and now I struggle to get the code from my gallery template to show in my page.

Or in other words …

Page: Team (basic-page.php)
basic-page.php has PageTable field
PageTable field has a block_gallery template
block_gallery.php has the code to show the gallery
… how can I show the gallery on the Team page?

Link to comment
Share on other sites

Using render() as kongondo suggests is good - here is some info from Ryan on the available options.

But I usually output from a PageTable the same way as I would a Repeater, e.g. if page_table_field is in the "basic page" template, in basic-page.php...

foreach($page->page_table_field as $p) {
    echo "<h3>{$p->title}</h3>";
    // etc, for other fields in the PageTable item template
}

 

  • Like 1
Link to comment
Share on other sites

Thanks Robin. I would do like you, but I've quite a lot of templates and all of them are totally different. It's more manageable for me to put them into their own templates.  However, thanks for the code! And thanks for the link. But I had more of an "how to use PageTable" doc in mind. Seems there is no dedicated documentation for it.

Link to comment
Share on other sites

Ok, that makes things a little bit more complicated (at least for me). 

There is currently one more question in my head.

How do I access page variables of the containing page? When using $page->parent->title I get the page in the Admin tree, not the page containing with the page table.

Link to comment
Share on other sites

1 hour ago, suntrop said:

How do I access page variables of the containing page?

You pass $page to the render method in the $options array.

From the post I linked to above:

Quote

If you made this render() call:


echo $page->render('myfile.php', array('foo' => 'bar')); 

myfile.php could access the 'foo' variable like this:


echo $options['foo']; // outputs "bar"

 

 

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...