douglas81 Posted October 1, 2014 Share Posted October 1, 2014 Assume I'm using the site-default template from the current 2.5.2 release/ In my page, I have fields "summary", "duration" and "instrument" I'm using this in my template: if($page->hasChildren) $content .= renderNav($page->children, 0, 'summary && duration && intrument'); Is that the correct way? I mean, using those && operators? It seems to work, but I just want to make sure it's the best and most efficient way. I may end up wanting to output about 10 fields and don't want it to slow things up. Link to comment Share on other sites More sharing options...
ottogal Posted October 1, 2014 Share Posted October 1, 2014 A look at the code of the function renderNav shows that several field names are expected to be separated by blanks: function renderNav($items, $maxDepth = 0, $fieldNames = '', $class = 'nav') { // ..................... if($fieldNames) foreach(explode(' ', $fieldNames) as $fieldName) { // ..................... 2 Link to comment Share on other sites More sharing options...
douglas81 Posted October 1, 2014 Author Share Posted October 1, 2014 Got it. That makes sense now. Here's another sort of related question. So, this nav will output the title of a page, and any the title of any extra field. That's great. Now, what if one of those fields is a repeater field. And what if I want to display each item within the repeater field? I set up this... foreach($item->my_repeater_field as $foo) { foreach($foo->my_multi_page_field as $bar) { $out .= $bar->get('my_field'); }; }; And it renders perfectly, as expected, but when I use it in conjunction with the nav function, it throws the following error... Warning: Invalid argument supplied for foreach() It's strange, because it actually works and outputs and loops through the fields as expected. Any clues? Link to comment Share on other sites More sharing options...
douglas81 Posted October 1, 2014 Author Share Posted October 1, 2014 I think I may have been mistaken. I was inserting this code in the wrong place. 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