Segment variables inside {exp:query}
Posted: 26 May 2008 09:52 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  248
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 02:13 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12376
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 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 27 May 2008 03:47 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  248
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 03:57 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12376
Joined  04-29-2002

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

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

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 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64908 Total Logged-in Users: 38
Total Topics: 81853 Total Anonymous Users: 22
Total Replies: 440062 Total Guests: 241
Total Posts: 521915    
Members ( View Memberlist )