Sending Parameters to A Page & Trapping them With Smarty
Posted: Wed Oct 31, 2007 6:29 pm
the cms_selflink page allows you to add parameters to the URL so that logic on the destination page can detect the parameters and display different things.
i.e add some content like this to a page:
Now when you refresh this page, you will see that the mode= parameter is added on to each of these links to the CMS testpage page.
Creating a page with the alias 'testpage', I then add code like this:
Going directly to this page, should tell you about an unknown mode
however, using one of the links created above should display different text.
This could be useful for re-using the same detail page to display different forms, or for a variety of purposes.
Just thought I'd pass on this little tip.
i.e add some content like this to a page:
Code: Select all
{cms_selflink page='testpage' text='do this' urlparam='&mode=dothis'}
{cms_selflink page='testpage' text='do that' urlparam='&mode=dothat'}
Creating a page with the alias 'testpage', I then add code like this:
Code: Select all
{if $smarty.get.mode == 'dothis'}
<h3>Do That</h3>
{elseif $smarty.get.mode == 'dothat'}
<h3>Do This</h3>
{else}
<strong>Error Unknown Mode</strong>
{/if}
however, using one of the links created above should display different text.
This could be useful for re-using the same detail page to display different forms, or for a variety of purposes.
Just thought I'd pass on this little tip.