I would personally implement it with a separate template, but there certainly is no such requirement. We can perform some small modifications so one does not get sent to a different page and optionally display the wishlist on the page-view as well:
- Code: Select all
<cms:template title='Products' clonable='1' dynamic_folders='1'/>
<cms:if k_is_page>
<cms:no_cache/>
<cms:set cookie_ids="<cms:get_cookie name='wishlist'/>"/>
<cms:set new_ids=cookie_ids scope='global'/>
<cms:set add="<cms:gpc 'add' method='get'/>"/>
<cms:set remove="<cms:gpc 'remove' method='get'/>"/>
<cms:set get_id="<cms:gpc 'id' method='get'/>" scope='global'/>
<!-- optional - if you want to display the wishlist --><cms:set current_page_link=k_page_link scope='global'/>
<cms:if add>
<cms:set new_ids=get_id scope='global'/>
<cms:each var=cookie_ids as='id' sep=','>
<cms:if id != get_id>
<cms:set new_ids="<cms:show new_ids/>,<cms:show id/>" scope='global'/>
</cms:if>
</cms:each>
</cms:if>
<cms:if remove>
<cms:set new_ids='' scope='global'/>
<cms:each var=cookie_ids as='id' sep=','>
<cms:if id != get_id>
<cms:set new_ids="<cms:if new_ids><cms:show new_ids/>,</cms:if><cms:show id/>" scope='global'/>
</cms:if>
</cms:each>
</cms:if>
<cms:each var=new_ids as='id' sep=','>
<cms:if id == k_page_id>
<cms:set is_wishlist='1' scope='global'/>
</cms:if>
<!-- optional cms:pages tag - if you want to display the wishlist -->
<cms:pages id=id limit='1'>
<a href="<cms:show k_page_link/>"><cms:show k_page_title/></a><br/>
<a href="<cms:show current_page_link/>?remove=1&id=<cms:show k_page_id/>">Remove</a><br/><br/>
</cms:pages>
</cms:each>
<cms:if new_ids != cookie_ids>
<cms:set_cookie name='wishlist' value=new_ids expire='0'/>
</cms:if>
<br/><br/><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a><br/>
<cms:if is_wishlist>
<a href="<cms:show k_page_link/>?remove=1&id=<cms:show k_page_id/>">Remove</a>
<cms:else/>
<a href="<cms:show k_page_link/>?add=1&id=<cms:show k_page_id/>">Add</a>
</cms:if>
</cms:if>