Extension, Module

Archived
Forum
(read-only)

Stash

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

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

     

Issue using Stash with exp:query

Support Request

LesterCallif
LesterCallif

I am trying to use the following code to set a Stash variable with the value received from a query statement.  The Stash variable is available within the exp:query and /exp:query, but it is not available outside of the query.

The following will display the variable - this is not what I want to do:
————————————————————————————————————————————-
{exp:query sql=“select Cons.FullDesc, Cons.ShortDesc
              from <?php echo $this->EE->db->dbprefix; ?>_contactyoubaby Cons
              Where 1=1 and Cons.CancelDt is NULL” }
 
    Name = {FullDesc}

    {exp:stash:set_list name=“my_list”}
        {stash:item_desc}{FullDesc}{/stash:item_desc}
    {/exp:stash:set_list}

    {exp:stash:get_list name=“my_list”}
      <h1>{item_desc}</h1>
    {/exp:stash:get_list}


{/exp:query}


The following does not show the variable - this IS what I would like to be able to do.
———————————————————————————————————————————————————————-
{exp:query sql=“select Cons.FullDesc, Cons.ShortDesc
              from <?php echo $this->EE->db->dbprefix; ?>contactyoubaby; Cons
              Where 1=1 and Cons.CancelDt is NULL” }
 
    Name = {FullDesc}

 

    {exp:stash:set_list name=“my_list”}
        {stash:item_desc}{FullDesc}{/stash:item_desc}
    {/exp:stash:set_list}

{/exp:query}

{exp:stash:get_list name=“my_list”}
  <h1>{item_desc}</h1>
{/exp:stash:get_list}

Mark Croxton
# 1
Developer
Mark Croxton

EE parses templates from the outermost module tags inwards, NOT linearly like a scripting language.

Add process=“end” to your stash:get_list to make it parse after the set:list.

 

LesterCallif
# 2
LesterCallif

Ohhh myyyyyy….  I was wondering if it was a parsing order, just did not see the process=“end” statement…

Which worked just as I wanted. Thanks for the help!!!!!