Nico Knoll Posted October 21, 2011 Share Posted October 21, 2011 Hi, I would like to have a field (e.g. a "custom field" like wordpress) which I can use multiple times maybe without predefining it. And which I can get in an foreach loop in my template or so. Greets, Nico Link to comment Share on other sites More sharing options...
Soma Posted October 22, 2011 Share Posted October 22, 2011 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 More sharing options...
diogo Posted October 22, 2011 Share Posted October 22, 2011 This was discussed before. Here is the topic that lead to the inclusion of repeatable fields on the roadmap http://processwire.com/talk/index.php/topic,53.msg168.html#msg168 Like Soma said, the default way of doing this in processwire is using the tree 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