Jump to content

Use some fields multiple times


Nico Knoll
 Share

Recommended Posts

Actually something like this is on the roadmap, but timeline is roughly aug.2012 http://processwire.com/about/roadmap/

But you could do it already using children pages. You can access them in the parent pages template in a foreach loop and even have different templates for each "sub-page" to select from. They don't even need to have a .php file, but you could still add one to do a a simple $session->redirect($page->parent->url); to the parent page if it's being accessed directly from a search result for example.

With this you can also sort them and extend it easily.

Or you could have the templates populate html markup like a list or box, and then use the page render() method (which is a module in PW) on the parent template to simply render them out.  Make them hidden or exclude them from the navigation with using a selector. -

A simple code snippet (or more complex) could be used to handle all.

<?php
$templ = "template=elem-body|elem-image-text|elem-title|elem-video";
if($page->children($templ)->count() > 0){
foreach($page->children($templ) as $elem){
	echo $elem->render();
}
}
?>

So this approach can be very powerful and simple. PW is designed to work very well this way. Not sure if something like this could be useful in your case, but just wanted to give a alternative. :)

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...