All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Can't edit or delete variables

maodiddy 24 May 2012 20:51 problem, complete

I just installed the module, entered my license and created two variables. I try to delete one and edit the other and although it says that changes were saved nothing actually changes... please help.

Replies

  1. Low 25 May 2012 07:49

    Hi Michael,

    Do you have any other add-ons that deal with global variables/snippets (like Libraree for example) installed?

    Also, for the record, what version of EE and Low Variables are you on?

  2. maodiddy 25 May 2012 21:44

    Yeah, I had libraree installed previously. I removed and now it works ok. However, I can't seem to get the variable working as I would like. I have read and followed Jamie Pittock's article here: http://jamiepittock.com/words/2012/ap... and I am using my variable in much the same way – trying to create an "embed" type of functionality...

    I have the variable "lv_sn_sub_nav" created with the following content (a Structure Entries sub nav, which must be parsed outside of the channel entries tags):

    {if "{exp:structure_entries parent="/{segment_1}" status="open"}{total_results}{/exp:structure_entries}" > "0"}


      {exp:structure_entries parent="/{segment_1}" include_parent="true" depth="2"}
    {if "{alt_page_title}" != ""}{alt_page_title}{if:else}{title}{/if}

    {/exp:structure_entries}
    {if "{segment_1}" == "community"}Forums{/if}

    {/if}

    And I have placed it in my template like so (some markup removed for brevity):

    {exp:channel:entries limit="1" disable="categories|member_data|pagination"}
    {exp:low_variables:parse var="lv_sn_sub_nav"}

    {title}


    {body}
    {/exp:channel:entries}

    As I understand it, the tag formatting and parameters above should parse this variable like an embed, correct? However, I get the following error:

    Parse error: syntax error, unexpected T_STRING in /home/tnitacti/cms/expressionengine/libraries/Functions.php(659) : eval()'d code on line 123

    Using Low Variables 2.2.1 and EE 2.4.0

  3. Low 26 May 2012 12:49

    The parse error you're getting most likely is caused by a botched conditional -- not necessarily caused by Low Variables.

    Can you paste your template code in something like http://pastie.org/ so everything is nicely concerted to entities?

    For now, be aware that the preferred way of writing conditionals is this:

    {if segment_1 == "community"} ... {/if} 
    {if alt_page_title != ""} ... {if:else} ... {/if}


    And be careful with adding whole tags in a conditional like you're doing with the structure_entries tag.

  4. maodiddy 30 May 2012 22:39

    Here is the code on Pastie: http://pastie.org/3998203

    I adjusted the conditionals but no difference. I usually do it the way you mention, but had tried some other ways to see if there was an issue there, as I thought it would be a botched conditional as well.

    Regarding the structure entries tag, this is the way recommended to me when you only want the structure entries sub nav to show up if there are actually sub pages. The code works flawlessly as an embed... maybe with the structure entries tag it needs to remain an embed...? Is it not possible as a Low Variable?

  5. Low 31 May 2012 08:29

    So, let me get this straight. You've got a Low Variable with the content that you've put in the Pastie. That var is inside a channel entries tag, like this:

    {exp:channel:entries} 
    {exp:low_variables:parse var="lv_sn_sub_nav"}
    {/exp:channel:entries}


    Is that correct? If it is, I can see some parse order issues. Take a look at this article first: http://gotolow.com/blog/parse-order-a...

    When using the {exp:low_variables:parse} tag, you're processing the var after the segment vars are being parsed. That means the {segment_x} variables inside the variable will remain unparsed, which could cause trouble.

    As I said, the error is caused by a faulty conditional, not necessarily by Low Variables. It's a matter of tracking down the conditional responsible for for it.

  6. maodiddy 2 Jun 2012 23:01

    I resolved any conditional issues and you are right, the segment variables aren't getting parsed, so it isn't outputting the sub navigation from the correct level. Is this an element that by it's nature MUST be an embed, or is there another method where it could work as a LowVariable...?

  7. maodiddy 2 Jun 2012 23:11

    Sorry if these are stupid questions. I'm still trying to get my head around how to use Low Variables effectively. I've read your parse order post, downloaded your PDF cheat sheet and read Jamie Pittock's post as well. From what I understand, you can use the exp:low_variables:parse tag to emulate how an embed would work, as long as you don't need to pass information through (like you would in an embed tag) or, as I have now found out, if you need to detect and use segments, etc... In those cases you would still need to use an embed, is that correct?

  8. Low 3 Jun 2012 12:19

    LV is not a 1 to 1 replacement for embeds per se. Embeds are all separate templates, so the template parser is run per embed -- the entire list you find in the pdf is handled step by step for each template/embed.

    A Low Variable (or snippet) is simply put into the template in the process of handling a single template.

    So, really, it's a matter of knowing which variables you can nest properly, which I explain in the blog post http://gotolow.com/blog/parse-order-a...

    With embeds, you trade in the parse order troubles for possible performance issues.

    Right now, using Jamie's approach (and looking at my blog post) and your LV content, there are #1 vars inside #2, which will not work. Using an embed will avoid this issue, but like I said, comes with a slight performance hit.

  9. Low 5 Jun 2012 12:33

    Low Variables 2.3.0 might help. With that, you can use something like this:

    {exp:low_variables:parse var="lv_sn_sub_nav" preparse:segment_2="{segment_2}"}


    ...which will preparse the {segment_2} variable before the Low Variable hits the template.

  10. maodiddy 5 Jun 2012 17:14

    that's awesome. As a feature request (not sure how difficult this would be), it would be really cool to be able to pass data through to the variable, kind of like an embed tag. If that negates any performance benefit of using a variable instead of an embed tag, then obviously it's not worth it, but otherwise it would be a great feature!

    Thanks for your help and hard work.
    -m

  11. Low 5 Jun 2012 19:12

    That's actually exactly what the preparse parameter will allow. For example, if you have a Textarea variable type "lv_sn_entries" with this content:

    {exp:channel:entries channel="{segment_1}"} 
    {title}
    {other_var}
    {/exp:channel:entries}


    And you use the new tag + parameter in your template:

    {exp:low_variables:single var="lv_sn_entries" preparse:segment_1="{segment_1}" preparse:other_var="Just like embed vars"}


    Then this is put into the template (if segment 1 is "news"):

    {exp:channel:entries channel="news"} 
    {title}
    Just like embed vars
    {/exp:channel:entries}


    ...so the channel entries tag can be parsed normally.

  12. maodiddy 5 Jun 2012 19:19

    Awesome! That is much more clear to me now. Thanks!
    -m

  13. ejaeDesign 5 Jun 2012 19:26

    Low Low Low!!! How Low Can You...

    Alright, jokes aside, this is quite supreme. Thank you :D

  14. Media Surgery 6 Jun 2012 12:59

    Quite outstanding, been waiting for this.