Assigning a Variable
Posted: 12 January 2005 03:59 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  281
Joined  11-22-2002

Is there a way of assigning a variable to a cookie and then have the variable in the Cookie recognized in embedded pages?

For example, I have a page that displays 3 weblogs (3 columns).  The portal page embeds the single pages for each weblog (3 embeds).  The embed pages define the weblog and include the if statement for the field (custom field) which exists in the three weblogs.

I’d like to be able to use the contents of a drop down variable so I don’t have to make a unique set of weblogs/templates for each user type. 

I’m thinking it could be something similar to the skins module that enables you to set the variable for the page on the fly.

I tried putting it in my portal page and having it feel the three embedded pages.  Wouldn’t I have the same problem with the variable not passing to the embedded pages, even if I was to get the cookie thing to work?

Profile
 
 
Posted: 12 January 2005 09:59 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

I’m not sure I understand your example, but just going off your initial question:

You ought to be able to use PHP to set a cookie value.  Whenever you wanted to use the value in a Template you’d then need to “retrieve” it for use using PHP just like normal:

$some_variable = $_COOKIE['your_cookie_setting'];

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 12 January 2005 10:54 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  281
Joined  11-22-2002

I’ll try to ‘splain it better:

Let’s say I have a drop down on the page that is:
Girl
Boy

The user picks “Girl.”

That is a custom field defined in three weblogs.  The pages call all three weblogs, on separate templates, embedded into the main one.  All three sub-templates need that variable to define what is displayed.

I tried testing it by setting up a fourth template that contained the variable definition and embedding it in the other three, but the system doesn’t seem to recognize the value from an external template.  (For example, the 4th template contained only the line “{assign_variable:boy_or_girl=“girl”}

Will it be able to parse the sub-templates into the main one, pulling only the values for “Girl” if I use a cookie rather than a template? 

Profile
 
 
Posted: 12 January 2005 12:29 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

Templates are all parsed separately (regardless of how they’re “embedded”) so values are not passed from one Template to another.

If you set a value in a cookie then you should be able to read that cookie value in each of your Templates using PHP and then use PHP within the Template to echo or use the variable however you want.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64978 Total Logged-in Users: 22
Total Topics: 82016 Total Anonymous Users: 19
Total Replies: 440814 Total Guests: 190
Total Posts: 522830    
Members ( View Memberlist )