This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
certain embeded words (“year”, “month”) parsed and replaced incorrectly
Posted: 03 July 2008 12:57 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  81
Joined  12-26-2006

I had to delve into core to find this nasty bug.

scenario:

In file A there is an embed call like so:

{embed="publikationen/notizen-view" by_year="{segment_3}"}

In file B there is a reference to the embedded variable by_year like so:

{exp:weblog:month_links weblog="notizen"}
      {year_heading}
      
<li><a href=""id="active">{year}</a></li>
      
{/year_heading}
{
/exp:weblog:month_links}

 


problem:

Unfortunately, because within the month_links tag {year} is a single variable, all variations of the word “year” within tags are replaced.  So instead of {embed:by_year} being replaced with the variable passed-in (segment_3’s value in the above case), it becomes “embed:by_2008” for the current year.  Here’s the output from core.php before it gets sent through the php evaluator:

<li><a href=""id="active">2008</a></li>

PHP barfs on ‘if(“2008” == embed:by_"2008”)’ with a syntax error stating an incorrectly placed “:”.

Would be nice if the parser would check surrounding characters to each single-variable.  i.e. {year} != {embed:by_year} when parsing smile

This is on EE1.6.3 - but I didn’t spot a reference to a similar fix for 1.6.4 ...

 Signature 

Majides, Inc.
Fuelling CodeIgniter and ExpressionEngine from Japan

Profile
 
 
Posted: 03 July 2008 01:00 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  582
Joined  04-29-2008

On it, thanks for the report.

Profile
 
 
Posted: 03 July 2008 02:32 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  582
Joined  04-29-2008

Am I correct in my assumption that you are referring to this setup?

Template 1

<p>{segment_3}</p>
{embed="group/template" by_year="{segment_3}"}

Template 2 (embeded in template 1)

<p>{embed:by_year}</p>
{exp:weblog:month_links weblog="local"}
    {year_heading}
        {if embed
:by_year == year}
            
<li><a href="{embed:by_year}"id="active">{year}</a></li>
        
{/if}
    {
/year_heading}
{
/exp:weblog:month_links}

Profile
 
 
Posted: 03 July 2008 06:27 PM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  81
Joined  12-26-2006

whoops - yes, I don’t know how I missed that one.  Must have removed the offending code (references to by_year inside the month_links tag) by accident.

bug?

 Signature 

Majides, Inc.
Fuelling CodeIgniter and ExpressionEngine from Japan

Profile
 
 
Posted: 04 July 2008 04:36 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  582
Joined  04-29-2008

This is a known issue. The current template parser expects early-parsed conditionals to be on the left-hand side of the conditional, and a quoted value to be on the right.  It’s unable to do so in this case. When the {exp:weblog:month_links} tag parses its conditionals, it gobbles the ‘year’ portion of ‘embed:by_year’, leaving:

{if embed:"2008" == "2008"}

Currently, a working solution is to reverse the conditional, and wrap the ‘matching phrase’ in quotes:

{if "{year}" == embed:by_year}

Also, while quoting a variable can pose a security risk (please see #6), it shouldn’t be a concern with {year}.

Profile
 
 
Posted: 10 July 2008 01:18 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  582
Joined  04-29-2008

housekeeping.

Profile
 
 
 

This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
 
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: 64889 Total Logged-in Users: 58
Total Topics: 81818 Total Anonymous Users: 43
Total Replies: 439873 Total Guests: 255
Total Posts: 521691    
Members ( View Memberlist )