Segment variables inside {exp:query}
Posted: 26 May 2008 10:52 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  301
Joined  12-11-2002

Can this be done (see use of segment_4 at end of query)?

{exp:query sql="SELECT status_id FROM exp_statuses AS s LEFT JOIN exp_weblog_titles AS t ON t.status = s.status WHERE t.weblog_id = '3' AND t.url_title = {segment_4}"}

This returns the correct value when a valid url_title is hard-coded, but not with the segment variable.

I have tried curly braces/no curly braces, single quotes/no single quotes, double quotes/no double quotes.

ExpressionEngine 1.6.3 - 20080319

Profile
 
 
Posted: 26 May 2008 03:13 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  21062
Joined  04-29-2002
t.url_title = '{segment_4}'

would be the way to go.

The rule for exp:query is to use single quotes.

But I’ll bet the problem is you need to use {segment_3} instead of {segment_4}.

http://example.com/index.php/segment_1/segment_2/segment_3
 Signature 

EE 2.01PB - 2.x Bug Tracker | Docs | Upgrade from 1.x to 2.x | Build Update Instructions | 1.6.x Update Info

Most recent 2.x version: Build 20100215
Don’t forget to upgrade MSM and Forum as needed!

Profile
MSG
 
 
Posted: 27 May 2008 04:47 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  301
Joined  12-11-2002

Yes, in fact that’s the case, but {segment_4} works correctly in a nearby {exp:weblog”:entries} tag. Why?

Profile
 
 
Posted: 27 May 2008 04:57 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  21062
Joined  04-29-2002

Without seeing the template you’re using this with, it’s hard to say.

 Signature 

EE 2.01PB - 2.x Bug Tracker | Docs | Upgrade from 1.x to 2.x | Build Update Instructions | 1.6.x Update Info

Most recent 2.x version: Build 20100215
Don’t forget to upgrade MSM and Forum as needed!

Profile
MSG
 
 
   
 
 
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 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120612 Total Logged-in Users: 80
Total Topics: 126647 Total Anonymous Users: 44
Total Replies: 665760 Total Guests: 477
Total Posts: 792407    
Members ( View Memberlist )