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.

 
 
Conditionals in [removed] element
Posted: 13 July 2008 05:04 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
Joined  04-12-2008

Hi

I just ran into a strange behaviour when using conditionals in my html head in a [removed] tag. The following example demonstrates the situation:

[removed]

{if embed
:gallery == "yes"}
    some thing here
.
{if:else}
    something
else here.
{/if}

[removed]

I’d expect this piece of code to result in

[removed]
    some thing here
.
[removed]

if the gallery embedded variable is set to “yes” or

[removed]
    something
else here.
[removed]

otherwise. Strangely using this piece of code, this is what I get in the resulting html:

[removed]

{if
"yes" == "yes"}
    some thing here
.
{if:else}
    something
else here.
{/if}

[removed]

The embedded variable is parsed correctly, however the conditionals seem to be forgotten. Putting the if - else part outside of the [removed] tag, e.g.

[removed]
    some script
[removed]

{if embed
:gallery == "yes"}
    some thing here
.
{if:else}
    something
else here.
{/if}

works as expected.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 13 July 2008 08:13 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

By default, EE conditionals are protected inside Javascript, because Javascript is frequently compacted, making a normal Javascript if/else block look like an EE conditional.  And of course, when EE parses that as a conditional, then the Javascript becomes broken If none of your Javascript fits this pattern, you can change this behavior if you like by using a config variable, ‘protect_javascript’, setting it to ‘n’.

 Signature 
Profile
MSG
 
 
Posted: 13 July 2008 08:22 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  246
Joined  04-12-2008

Thanks Derek, can by marked as resolved then.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 13 July 2008 08:29 AM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15831
Joined  06-03-2002

You’re most welcome.

 Signature 
Profile
MSG
 
 
 

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: 64938 Total Logged-in Users: 53
Total Topics: 81910 Total Anonymous Users: 52
Total Replies: 440318 Total Guests: 295
Total Posts: 522228    
Members ( View Memberlist )