Forum
Custom content several pages and regions loop
Hi,
I'm trying to retrieve a snippet of data on the main products page, so it lists the 'product groups' with content from the product group page but then also as part of that I want to retrieve the products that are within that group.
/products/
/products/product_group/index.php
/products/product_group/product_name.php
/products/another_product_group/index.php
/products/another_product_group/another_product_name.php
So in basic terms the output would be something like:
Product Group Name,
Product Group Description,
Product Group Link
Products within group:
Product Name 1 & Link,
Product Name 2 & Link,
Product Name 3 & Link
Then output the next group until all are listed.
This gets the data from multiple sources but can't fathom how to adjust for my needs. https://solutions.grabaperch.com/architecture/content-from-multiple-pages-and-regions
Any ideas please?
Thanks
How is your data structured?
Using Blocks and perch:template. So Product Groups and Products are sharing the same code and id's. Reusing the same templates for all the data just products have more detail added obviously. I only need to grab minimal data as above, so what I need is common on both Groups and Products.
<!--* Main heading and introduction and graphic *--> <perch:before> <perch:template path="content/blocks/introduction_block.html" /> </perch:before>
<perch:blocks divider-before="Choose content block to suit you're content as many or little as you want, you can even reorder them.">
</perch:blocks>
ps. this page won't load for me: https://support.grabaperch.com/formatting
How and where is the group data stored?
All data is added per page and region, NOT list and detail.
Custom content to load and list groups and products on:
/products/index.php
Product Groups:
/products/group-name/index.php
template = Group_detail.html
Products (multiple):
/products/group-name/product-name.php
template = product_detail.html
Both above share Blocks with some extra for Products, but I don't need to grab any of the extra data.
So on a certain Group page I'm also listing products within that group page like so:
Does that make sense?
So the process would be:
Get all the group data
Loop through it and get the product data for each group
Is that right?
yes that's correct, so listed on the page it would have X Product Group and associated Products, then the next X Product Group with it's associated products and so on until they are all listed.
Ok, great. At which point are you stuck?
I can get both sets of data e.g. Group & Products but not combine them. As the group and product data is from different regions I don't understand how to load the group from one region and page and then process products in that group data before moving onto the next group. I can only get the data to load separately not combined.
Ok - are you using
skip-template
to get the data? Can you show me what you have for the groups and we can loop through it.