ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Strange Var Behaviour

April 08, 2009 11:01pm

Subscribe [2]
  • #1 / Apr 08, 2009 11:01pm

    Andrew Smith

    95 posts

    Assume {segment_2} = “hi-there”

    I’m doing the following.

    {assign_variable:foo="{exp:tag:tag_name}{segment_2}{/exp:tag:tag_name}"}
    
    {foo} // outputs "hi there"
    
    {exp:query sql='SELECT * FROM exp_weblog_titles WHERE title = "{foo"}'}

    That query is processing as,

    SELECT * FROM exp_weblog_titles WHERE title = "M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr"

    Why?

  • #2 / Apr 09, 2009 1:24am

    John Henry Donovan

    12339 posts

    Andrew,

    You problem here has to do with the Parse Order of the template.


    Can I ask why you don’t just use this

    {exp:query sql="SELECT * FROM exp_weblog_titles WHERE title = '{segment_2}'"}
  • #3 / Apr 09, 2009 1:25am

    Andrew Smith

    95 posts

    This is a simplified version of what we’re doing really, but fundamentally we need the hyphen removed from the string.

    I’ll have a look at parse ordering.

    Thank you.

  • #4 / Apr 09, 2009 1:42am

    John Henry Donovan

    12339 posts

    Andrew,

    Why not use url_tile instead?

    {exp:query sql="SELECT * FROM exp_weblog_titles WHERE url_title = '{segment_2}'"}

    EE Docs :  Weblog Entries - Single Variables - url_title

  • #5 / Apr 09, 2009 1:43am

    Andrew Smith

    95 posts

    Yep, like I said, that query is simplified, I’ve gotten around the problem though by placing the query in an embed and passing the variable.

    All is well now thanks for your help 😊

  • #6 / Apr 09, 2009 2:02am

    John Henry Donovan

    12339 posts

    Glad you found a solution. Feel free to post again if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases