Forum

Thread tagged as: Question

sitemap with collections

I have a sitemap displaying (screenshot below)

https://www.awesomescreenshot.com/image/1032349/03a0530c88ed8537886dc2e363b151d8

My code is the following using the default item.html template

perch_pages_navigation(array(
    'from-path' => '/'.REGION,
    'include-hidden' => true
));

My question is, from the screenshot above how would I go about adding my product collections under the products link of each segment?

My collections are displayed like this


perch_collection('foodservice '.REGION, [ 'template' => 'products/_sitemap_products.html' ]); perch_collection('Building Care '.REGION, [ 'template' => 'products/_sitemap_products.html' ]); perch_collection('Industry '.REGION, [ 'template' => 'products/_sitemap_products.html' ]); perch_collection('Health Care '.REGION, [ 'template' => 'products/_sitemap_products.html' ]); perch_collection('Automotive '.REGION, [ 'template' => 'products/_sitemap_products.html' ]); perch_collection('Aerospace '.REGION, [ 'template' => 'products/_sitemap_products.html' ]);
  • side note - I have created separate collections due to the fact each segment has a different set of filter configurations (See screenshot)

https://www.awesomescreenshot.com/image/1032361/3c6af89660e46df8f64878f5cc860e06

Link here - https://chicopee.teamfc.uk/en-eu/segments/foodservice/products

Would this be even possible?

Fishtank Creative

Fishtank Creative 2 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Pass the result into the template:

PerchSystem::set_var('foodservice', perch_collection('foodservice '.REGION, [
    'template' => 'products/_sitemap_products.html'
], true));

and then in your template, output it wherever you want:

<perch:if id="pagePath" value="/products/or/whatever">
     <perch:pages id="foodservice" encode="false" />
</perch:if>

Boom!!!