croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Setting variable in layout not passing value from child template #181

Open GitTworn opened 1 year ago

GitTworn commented 1 year ago

In the global (most outer) layout I would like to get some member variables and pass them on the a template that uses.

_global_layout

{if logged_in}
    {exp:stash:set scope='user' parse_tags='yes' save="yes"}
        {exp:visitor:details}
            {stash:st_logged_in_member_gender}{visitor:member_gender}{/stash:st_logged_in_member_gender}
            {stash:st_logged_in_member_first_name}{visitor:member_firstname}{/stash:st_logged_in_member_first_name}
            {stash:st_logged_in_member_last_name}{visitor:member_lastname}{/stash:st_logged_in_member_last_name}
            {stash:st_logged_in_member_email}{visitor:username}{/stash:st_logged_in_member_email}
        {/exp:visitor:details}
    {/exp:stash:set}
{/if}

In a child template I want to use them.

_newsletter_form <input type="text" class="form-control" id="first_name" name="first_name" placeholder="First name" value="{if {exp:stash:not_empty name='st_logged_in_member_first_name'}}{exp:stash:get name='st_logged_in_member_first_name'}{/if}"> OR <input id='radio-mr' type="radio" name="gender" value="male" {if '{stash:embed:st_logged_in_member_gender}' == 'male'}checked="checked"{/if}> <--- does not work either

This is not working.

When I use {stash:embed:st_logged_in_member_first_name} it does give me the correct value, however I can't seem to get it to work with a conditional.