0

New to Stash and here is what I'm trying to accomplish. But so far, no such luck.

I have two templates - manage-social-media.html and .layout-account.html

Manage-social-media.html Here I am gathering all of my content to pass to the layout-account template. I am using Zoo Visitor, and I have a custom field for “Permissions” (cf_member_firm_permissions) that I’d like to check to see if they can edit their content, or view only. So the custom field (Fieldpack - Dropdown) looks like this:

... : Select One read-only : Read Only editor : Editor

What I want to do is test that variable to see what it is, then set some stash variables accordingly. Mainly, if they are read-only, I’d like to do the following:

Set Stash variable for: “Read Only Message” - To tell them why they are unable to edit, and who they can contact. Set Stash variable for: “Disalbe form” - I was thinking that I would just add the stash variable (i.e. “disable” to the form fields so they could read them but not edit. Any other suggestions?

So I got the value for {cf_member_firm_permissions} by doing the following:

{exp:zoo_visitor:details} 
    {cf_member_firm_permissions}
{/exp:zoo_visitor:details} 

From there, I can’t get it to work. I’ve tried wrapping the above in a “stash”, wrapping the above around a “stash”, using a switchee statement to test the value of {cf_member_firm_permissions}, using a switchee statement to test the value of stash:user_permissions (after I’ve set it). I can’t get anything to do what I want.

Of course, all of the above is set within a stash variable “main_content” which is pulled into the layout template.

Here is some of the code that I've tried:

{exp:zoo_visitor:details}
    {exp:switchee variable="{cf_member_firm_permissions}" parse="inward"}
        {case value="read-only"}
        <h3>Hello Reader Permissions</h3>
        {exp:stash:set name="permissions"} disabled{/exp:stash:set}

        {/case}

        {case value="editor"}
        <h3>Hello Editor Permissions</h3>
        {/case}
    {/exp:switchee}
{/exp:zoo_visitor:details}

It displays "Hello Reader Permissions", but won't display anything else.

6
  • Probably need to see more of your code. Make sure you have parse_tags="yes" and parse_depth params added to your stash set tag. Your stash might not be parsing the zoo tag. Does your main_content var pull anything into layout-account? Commented Sep 18, 2014 at 11:03
  • Sorry for the delay. My main_content var pulls the other content, that is basic channel entries stuff. I was even trying to just post the values of the stash variables and that wasn't working. My code has changed so many times that I'll have to run a few more tests and repost. I was using parse_tags="yes", but not the parse_depth (wasn't aware of that). I will try that and see. Is it better to wrap the stash around the {exp:zoo_visitor:details}, or the other way around?
    – Todd
    Commented Sep 19, 2014 at 14:04
  • 1
    What about rethinking your approach a bit, and using switchee just output the form in the case of an editor, and output form values (minus the form) in the case of read-only? Or is your form on the layout template? Commented Sep 21, 2014 at 2:05
  • Where are you getting the permissions variable (I can see where it's set, but there's no get tag)?
    – Tyssen
    Commented Sep 21, 2014 at 2:40
  • @Tyssen I didn't include that but it was right below. I used both a {exp:stash:get name="permissions"} and {exp:stash:permissions} - neither of them worked.
    – Todd
    Commented Sep 21, 2014 at 20:11

2 Answers 2

0

If you're setting and getting in the same template, I think you need {exp:stash:parse}.

0

Here is what I ended up doing

{exp:zoo_visitor:details}
     {exp:stash:set name="permissions"}{cf_member_firm_permissions}{/exp:stash:set}
{/exp:zoo_visitor:details}

Then this is below

{exp:stash:main_content}
    {exp:switchee variable="stash:permissions" parse="inward"}
       {case value="editor"}
         Do this....
         My editable form
       {/case}
       {case value="read-only"}
         Do this....
         My read-only form
       {/case}
    {/exp:switchee}
{/exp:stash:main_content}

Everything seems to be working with this set up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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