by
KK » Mon Jan 11, 2016 2:00 pm
Hi Jiwa

We can use specify 'id' or 'page_name' parameters with cms:pages tag to fetch any particular single page.
We can also use the cms:pages tag multiple times (twice in our case) on the same page to fetch and show different pages on the same screen.
So there we have our comparison - we just need to show multiple pages (products) side-by-side on the same page.
We now only have to decide how to pass the ids or names of the pages to be displayed.
One easy way would be to use a separate uncloned template only for showing the comparision (say named 'compare.php').
From the main products page, we can invoke the above template passing it two querystring parameters representing the ids of the two pages to compare e.g.
http://yoursite.com/compare.php?product1=200&product2=400
On the compare.php template we retrieve the two ids and then use them in the two cms:pages block to show the two products side by side.
One way would be -
- Code: Select all
<!-- get product1 ID -->
<cms:set my_productid_1="<cms:gpc method='get' var='product1' />"/>
<cms:if "<cms:not "<cms:validate my_productid_1 validator='non_zero_integer' />" />" >
<cms:set my_productid_1= '0' />
</cms:if>
<!-- get product2 ID -->
<cms:set my_productid_2="<cms:gpc method='get' var='product2' />"/>
<cms:if "<cms:not "<cms:validate my_productid_2 validator='non_zero_integer' />" />" >
<cms:set my_productid_2= '0' />
</cms:if>
<!-- compare the two products -->
<cms:pages masterpage='products.php' id=my_productid_1 limit='1'>
<h2><cms:show k_page_title /></h2>
..
</cms:pages>
<cms:pages masterpage='products.php' id=my_productid_2 limit='1'>
<h2><cms:show k_page_title /></h2>
..
</cms:pages
Hope it helps.