Forum
Taking two navigations and mixing together to output in alphabetical order
Hi Guys,
Any pointers on this?
I have this code;
$url = perch_page_url(array(
'hide-extensions' => false,
'hide-default-doc' => true,
'add-trailing-slash' => false,
'include-domain' => false,
), true);
//This code splits the current page URL into strings after each '/'
//We then use this to choose the right products for each page as each path/URL is different. So this is passed into the perch_pages_navigation function to get the products for that section .E.G /land-products/electrical-resistivity
$url_paths = explode('/', substr($url, 1), 2);
$url_nav = "/".$url_paths[1];
echo '<ul class="related-products">';
$products = perch_pages_navigation(array(
'from-path' => $url_nav,
'flat' => false,
'template' => 'product_teaser.html',
'include-hidden' => true,
'siblings' => false,
'include-parent' => false,
'hide-extensions' => true,
'hide-default-doc' => true,
));
$products_rentals_only = perch_pages_navigation(array(
'from-path' => '*',
'flat' => false,
'template' => 'product_teaser.html',
'include-hidden' => true,
'siblings' => false,
'include-parent' => false,
'hide-extensions' => true,
'hide-default-doc' => true,
));
echo '</ul>';
I have two lots of perch_pages_navigation - pulling from two different sections. What I would like to do is put them into one array and then sort them alphabetically and use that template (product_teaser.html) to output….
Any ideas or can you push me in the right direction?
You need to use the
skip-template
option to return an array.Whoops. Sorry Drew. I pasted in the wrong code. This is my code; How do I get the arrays into one and then reorder that and then output that new array into the product_teaser.html' template?
This isn't really a Perch question, but you'll need to catch the output of
array_merge()
- at the moment you're merging and throwing the result away.If anyone is interested then I have solved it like this;
Drew, thanks for input. If you have any recommendations to improve on the above code then feel free :-)
Thanks, Terry