Question about queries under conditionals
Posted: 20 September 2007 03:57 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  375
Joined  10-20-2005

Here’s another question.y Let’s supppose I’ve got this code:

{if segment_2==""}{exp:weblog:entries weblog="weblog1" limit="1"}{/exp:weblog}
{if
:else}{exp:weblog:entries weblog="weblog2" limit="1"}{/exp:weblog}{/if}

When the url is using a segment2, does the template queries weblog1 and weblog2?
I think it should not but on the debugging it appears as it does.
Thank you.

Profile
 
 
Posted: 20 September 2007 07:13 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23538
Joined  05-20-2002

Yes- with complex conditionals, both queries happen- it’s just affecting display.  However, with simple conditionals, the conditionals are parsed earlier.  So you only get one query using simple conditionals, both queries with complex.  (Slightly simplified, but that’s the gist.)

Make sense?

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 20 September 2007 08:25 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  375
Joined  10-20-2005

I see. No sense. Also asking for the segment parameter should a be simple conditional.

Profile
 
 
Posted: 20 September 2007 08:56 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23538
Joined  05-20-2002

It’s the ‘else’ that makes it a complex conditional.  So:

{if segment_2==""}{exp:weblog:entries weblog="weblog1" limit="1"}{/exp:weblog}{/if}
{if segment_2
!= ""}{exp:weblog:entries weblog="weblog2" limit="1"}{/exp:weblog}{/if}


That would be two simple conditionals- and the weblog tag would only run once- for the one that meets the conditions.  Basically?  Complex and simple conditionals fall at different spots in the parse order- thus they will behave differently.

 Signature 

AKA rob1

Help Request TipsPro Network

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: 65026 Total Logged-in Users: 42
Total Topics: 82116 Total Anonymous Users: 17
Total Replies: 441305 Total Guests: 196
Total Posts: 523421    
Members ( View Memberlist )
Newest Members:  meenoiYang.JianuoioitsukiNathan HammondalexcigadamstaneckiLucas Mayscybermilltstitt