0

I am trying to set a group of stash variables per an entry and use them in the rest of the site build but I can't 'get' the stash variables from outside the initial channel entries tag.

So something like below in which if I place the tags inside the closing channel entry tag they will appear, but as they are will not.

{!-- STASH SET --}
{exp:channel:entries
    channel="site_settings" 
    limit="1" 
    disable="categories|member_data|pagination"
}
    {exp:stash:logo}{company_logo}{/exp:stash:logo}
    {exp:stash:style}{site_appearance_style}{/exp:stash:style}
    {exp:stash:color}{site_color_theme}{/exp:stash:color}
    {exp:stash:phone}{contact_phone_number}{/exp:stash:phone}
    {!-- GRID FIELDS --}
    {contact_e_mail_options}
        {exp:stash:text}{contact_e_mail_options:display_text}{/exp:stash:text}
        {exp:stash:email}{contact_e_mail_options:e_mail_address}{/exp:stash:email}
        {exp:stash:subject}{contact_e_mail_options:e_mail_subject}{/exp:stash:subject}
    {/contact_e_mail_options}
    {social_media_accounts}
        {exp:stash:facebook}{social_media_accounts:facebook}{/exp:stash:facebook}
        {exp:stash:twitter}{social_media_accounts:twitter}{/exp:stash:twitter}
        {exp:stash:linkedin}{social_media_accounts:linkedin}{/exp:stash:linkedin}
    {/social_media_accounts}
    {physical_address}
        {exp:stash:street}{physical_address:street}{/exp:stash:street}
        {exp:stash:city}{physical_address:city}{/exp:stash:city}
        {exp:stash:state}{physical_address:state}{/exp:stash:state}
        {exp:stash:country}{physical_address:country}{/exp:stash:country}
        {exp:stash:zip}{physical_address:postal_code}{/exp:stash:zip}
    {/physical_address}
{/exp:channel:entries}
{!-- /STASH SET --}

<h1>{exp:stash:logo}</h1>
<h1>{exp:stash:style}</h1>
<h1>{exp:stash:color}</h1>
<h1>{exp:stash:phone}</h1>
<h1>{exp:stash:text}</h1>
<h1>{exp:stash:email}</h1>
<h1>{exp:stash:subject}</h1>
<h1>{exp:stash:facebook}</h1>
<h1>{exp:stash:twitter}</h1>
<h1>{exp:stash:linkedin}</h1>
<h1>{exp:stash:street}</h1>
<h1>{exp:stash:city}</h1>
<h1>{exp:stash:state}</h1>
<h1>{exp:stash:country}</h1>
<h1>{exp:stash:zip}</h1>
3

The :set tags are not wrong, per se, as you are using the shorthand syntax. However, due to parse order, your 'get' tags are parsing before your 'set' tags since the sets are within the channel entries module tag.

Stephen's answer does fix things, because it moves the channel loop within the set module tags. (However, that is not always convenient.) You could also have fixed your issue by adding process="end" to the get tag, e.g.:

<h1>{exp:stash:logo process="end"}<h1>

to force it to parse after the channel loop, or you could wrap all the get tags in a {exp:stash:parse process="end"}.

1

Your :set tags are wrong. See docs here.

{!-- STASH SET --}
{exp:stash:set parse_tags="yes"}
  {exp:channel:entries
    channel="site_settings" 
    limit="1" 
    disable="categories|member_data|pagination"
  }
    {stash:logo}{company_logo}{/stash:logo}
    {stash:style}{site_appearance_style}{/stash:style}
    {stash:color}{site_color_theme}{/stash:color}
    ...continue that format...
  {/exp:channel:entries}
{/exp:stash:set}
{!-- /STASH SET --}

Then you get the values like this:

{stash:logo}
{stash:style}
{stash:color}
  • I tried both ways initially. I was using the short tags method shown in the docs here I'll try again that way though... – W3bGuy May 27 '14 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.