mixing embed variables inside EE weblog tags for conditional parameters
Posted: 03 July 2008 03:03 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  72
Joined  12-26-2006

Probably has to do with how EE parses it’s own tags vs. PHP tags (and the input/output mix), but I had to fiddle with some nested EE tags and landed on a way that didn’t seem obvious to me so I thought I’d share.

Basically i have an embedded variable I use to determine whether to switch a weblog parameter on or off.  In one particular case though, I need to also compare with the current year.  So in all, I have EE tags nested 3 deep.  The current_time one was causing problems (read: not working) until I wrapped it in single quotes.  So here’s what I thought would work:

{exp:weblog:entries weblog="notizen" {if embed:by_jahr > 0} year="{embed:by_jahr}" {/if} {if embed:by_jahr == {current_time format="%Y"}} offset="1" {/if} orderby="date" sort="desc" dynamic="off" disable="pagination|trackbacks"}

and here’s what actually works:

{exp:weblog:entries weblog="notizen" {if embed:by_jahr > 0} year="{embed:by_jahr}" {/if} {if embed:by_jahr == '{current_time format="%Y"}'} offset="1" {/if} orderby="date" sort="desc" dynamic="off" disable="pagination|trackbacks"}

Just to save someone else a few minutes in the future.

 Signature 

Fuelling CodeIgniter and ExpressionEngine from Japan

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 10:33 AM
Total Registered Members: 61036 Total Logged-in Users: 28
Total Topics: 73818 Total Anonymous Users: 15
Total Replies: 398205 Total Guests: 511
Total Posts: 472023    
Members ( View Memberlist )