Link parameter to set different template?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
appleyard
Forum Members
Forum Members
Posts: 27
Joined: Wed Dec 30, 2009 2:54 pm

Link parameter to set different template?

Post by appleyard »

Hi there,

I'm trying to set up a "print page" link on my site, and the {print} tag will not work for me for several reasons. (I use Textile formatting in my main content block, there are additional custom content blocks, etc.)

It seems like the easiest thing to do would be to create a template that strips out the menu and other elements, but lets me style the other things how I want, and use {cms_selflink} to link to that using some parameter that forces the specific template. But for the life of me I can't find anything in the documentation that shows how to do that. Can anyone help? Thanks!
tomgsd
Forum Members
Forum Members
Posts: 74
Joined: Tue Feb 12, 2008 10:00 am

Re: Link parameter to set different template?

Post by tomgsd »

You could use an additional get variable in the url and then use smarty to vary the output in your main template.  For example:

Code: Select all

www.yoursite.co.uk/page?printable=true
Then in the template:

Code: Select all

{if $smarty.get.printable}
    print only stuff
{else}
    normal stuff
{/if}
Hope this helps!
Green Sheep Design Ltd. - www.greensheep.co.uk
appleyard
Forum Members
Forum Members
Posts: 27
Joined: Wed Dec 30, 2009 2:54 pm

Re: Link parameter to set different template?

Post by appleyard »

Thanks, I'll try that!

However, I'm still curious: is there not a way to serve content in a different template based on the results of an {if} statement or Javascript check? That would be helpful for my printing issue, but also for serving a touch-optimized site to mobile devices, etc.
tomgsd
Forum Members
Forum Members
Posts: 74
Joined: Tue Feb 12, 2008 10:00 am

Re: Link parameter to set different template?

Post by tomgsd »

As far as I'm aware it's not possible.  However, there are other means like alternative stylesheets (using media="print, handheld, etc").

Also, you could create multiple content blocks in your template ({content block="block1, block2, etc"}) and show different content that way.  I always use the AdvancedContent module to do this sort of thing because it gives tons more options on the editing side - you can even use things like checkboxes which are a great feature.

More recently, I've managed to create some sites with a single template and then allow users to turn on/off sideboxes or switch layouts when editing the content.  I don't think it would be too difficult to have a UDT to detect a mobile browser and serve up different content in a similar way.
Green Sheep Design Ltd. - www.greensheep.co.uk
Post Reply

Return to “CMSMS Core”