Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » Chameleon / ChameleonLite
- » ChameleonLite
- » template based in my session var
template based in my session var
template based in my session var
I crreate a session variable from a particular value in a component directory.
Each entry to the directory (Sobi) can select the template you want to see your ad
ato enter each detail view, I create a variable sessión from the value (green, blue, oranje...)
$_SESSION ['template'] = $field_value_of_Sobi2;
in metatemplate rules put in PHP
based template in my session var
if ($_SESSION ['template'] == "Blue") return "Blue";
if ($_SESSION ['template'] == "Orange") return "Orange";
if ($_SESSION ['template'] == "Green") return "Green";
but don´t work
other opction
if ($_SESSION ['template'])
return "".$_SESSION ['template']."";
but don´t work
I need the value of the session and load the associated template
thanks form yur help and the component
sorry 4 my english
02-Jun-10 15:21:25
Re: template based in my session var
Hi Spock,
(1) if you want to change the current template immediately, by code inside SOBI2 [I think that's what you are saying, when you set the session], then this can't work. That's because the template already has to be set before any of the component code is executed. So the template gets set first; then the code inside the template, the SOBI2 code and the module code are executed.
(2) Therefore, if that's what you are trying to achieve, then you may be able to achieve this effect by moving the code from SOBI2 into the MetaTemplate PHP box.
(3) You may also have more success using the Joomla methods for sessions, instead of $_SESSION. Perhaps try this instead:
To set:
$session =& JFactory::getSession();
$session->set( "template", "Blue", 'mysite'); // "mysite" is a namespace for your session variables
To retrieve:
$session =& JFactory::getSession();
$session->get( "template", "", 'mysite'); // "" is the default value
Hope that helps,
Stephen
- Index
- » Chameleon / ChameleonLite
- » ChameleonLite
- » template based in my session var
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 1
- User Info:
- Total Users:
- 7667
- Newest User:
- humble2601
- Members Online:
- 0
- Guests Online:
- 97
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked