Plugin

Archived
Forum
(read-only)

String

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From eMarketSouth

     

String Output does not convert variables to their values in templates that use exp:query (Query module installed on EE)

General

HotLimbo
HotLimbo

String output converts the variables I have set such as {lat1} or {lon1} in the main template to its values in any embedded template as long as it is not used inside the {exp:query}{/exp:query} module tags.

The code below shows my embedded template code.

{lat1} or {lon1} convert to their variable’s value (which btw is latitude and longitude) if outside {exp:query} tags but not inside. This should work as the embedded template is parsed by EE for the variables prior to the {exp:query} module going to work on the database.

Any ideas what could be going on here?

{exp:string:output }
    {exp
:query
        sql
="SELECT 
  exp_channel_data.entry_id,
  exp_channel_titles.url_title,
  exp_channel_titles.entry_id,
        exp_channel_images.entry_id,
        exp_channel_images.filename,
        exp_channel_images.extension,
  exp_channel_titles.title,
                exp_channel_data.field_id_70, 
                exp_channel_data.field_id_78, 
                exp_channel_data.field_id_79,
                exp_channel_data.field_id_154, 
                ( 6371 * acos( cos( radians( {lat1} ) )
                 * cos( radians( exp_channel_data.field_id_78 ) )
                 * cos( radians( exp_channel_data.field_id_79 )
                 - radians( {lon1} ) )
                 + sin( radians( {lat1} ) )
                 * sin( radians( exp_channel_data.field_id_78 ) ) ) ) 
                AS distance 
            FROM exp_channel_data
  INNER JOIN exp_channel_titles
  ON exp_channel_data.entry_id=exp_channel_titles.entry_id
        INNER JOIN exp_channel_images
  ON exp_channel_data.entry_id=exp_channel_images.entry_id
            HAVING (distance BETWEEN 0.01 AND 50)
            ORDER BY distance 
            LIMIT 0, 20"
    
}



        
<li><a href="{path=/property/homepage/{url_title}}"><img class="l-float-left" src='http://www.mysite.com/assets/uploads/logos/{entry_id}/{exp:ce_str:ing substr="0|-4"}{filename}{/exp:ce_str:ing}__tiny.{extension}' width='50' height='50' border='0'><div>{title}</div></a><div>({exp:ce_str:ing number_format="1|.|"}{distance}{/exp:ce_str:ing} km away)</div><br clear="both" /></li

    
{/exp:query}
{
/exp:string:output} 
eMarketSouth
# 1
Developer
eMarketSouth

Try adding parse=“inward” to your {exp:string:output} tag, that’ll force the string variables to be evaluated first.

{exp:string:output parse="inward"}
    {exp
:query
        sql
="SELECT 
  exp_channel_data.entry_id,
  exp_channel_titles.url_title,
  exp_channel_titles.entry_id,
... 
HotLimbo
# 2
HotLimbo

Hey, parse=“inward” did the job. Thank you very much for the time you spent replying to the above support request. Much appreciatted.