How to set and read a session variable?
Posted: Fri Aug 03, 2012 12:35 pm
I have the following template working:
You can see this at http://onemansweb.org/mobs
What I would like to do is to add a link or button in the content block I have assigned as 'freddy' which would assign a session variable I would call 'forcefullsite'. Then I could use the following logic.
This would allow mobile users to force the full site layout. I am retrofitting a couple of very large websites to allow a better mobile experience and this logic would minimise my rewriting task.
Question: Can I set a variable as I propose? Can anyone give me the three or four lines of code I would need? I am already way outside my limited skill level
Many thanks
Andrew Prior
Code: Select all
{content assign='freddy'}
{mobile}{capture assign='mobiletemp'}{$mobile_detect}{/capture} {* UDT from Goran Ilic *}
{if $mobiletemp}
{cms_stylesheet name='mobile'}
{$freddy}
{else}
{cms_stylesheet name='full'}
{various menus and columns etc}
{$freddy}
{/if}
What I would like to do is to add a link or button in the content block I have assigned as 'freddy' which would assign a session variable I would call 'forcefullsite'. Then I could use the following logic.
Code: Select all
{content assign='freddy' NOW INCLUDES THE BUTTON}
{[mock code] if session variable equals forcefullsite [/mockcode]}
{cms_stylesheet name='full'}
{various menus and columns etc}
{$freddy}
{else}
{mobile}{capture assign='mobiletemp'}{$mobile_detect} {/capture} {* UDT from Goran Ilic *}
{if $mobiletemp}
{cms_stylesheet name='mobile'}
{$freddy}
{else}
{cms_stylesheet name='full'}
{various menus and columns etc}
{$freddy}
{/if}
Question: Can I set a variable as I propose? Can anyone give me the three or four lines of code I would need? I am already way outside my limited skill level

Many thanks
Andrew Prior