Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

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

Edited By: Spock
02-Jun-10 14:21:25

Spock
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: template based in my session var

I think it can not function
because the session is established once data is loaded

when reloading the page works but not what I need

seek alternatives in other post

Spock
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5914
Total Posts Today:
1
User Info:
 
Total Users:
10816
Newest User:
sakmy567q
Members Online:
0
Guests Online:
70

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