1

In my stash partial, I have:

{!-- Custom Sidebar? --}
{if "{exp:stash:get name='custom_sidebar_text'}"}
  <section class="container">
    {if "{exp:stash:get name='custom_sidebar_title'}"}
      <h3>
        {exp:stash:get name='custom_sidebar_title'}
      </h3>
    {/if}
    {exp:stash:get name='custom_sidebar_text' random}
  </section>
{/if}
{!-- /Custom Sidebar --}

In my template I have this:

{embed="layouts/.landing_page"}
{exp:channel:entries}
  {exp:stash:set parse_tags="yes" parse_conditionals="yes"}
    {!-- Several other stash variables --}
    {stash:custom_sidebar_title}{custom_sidebar_title}{/stash:custom_sidebar_title}
    {stash:custom_sidebar_text}{custom_sidebar_text}{/stash:custom_sidebar_text}
  {/exp:stash:set}
{/exp:channel:entries}

I’m getting a warning saying:

A PHP Error was encountered
Severity: User Warning
Message: Invalid EE
Conditional Variable: {if "
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Users/agarzola/git/wfgc/system/codeigniter/system/core/Exceptions.php:170)
Filename: core/Common.php
Line Number: 412

If I remove the outermost conditional tags in the partial ({if "{exp:stash:get name='custom_sidebar_text'}"} and '{/if}'), the markup is rendered perfectly, with the stash variables parsed as expected.

edited to add: This only happens when the custom_sidebar_text field contains a link (generated via Wygwam in this case). Take away the link on the edit entry form, save the page, and the error goes away.

1 Answer 1

1

This is because the hyperlink in your stashed variable likely contains double quotes, which is also the delimiter you're using to contain the conditional. So you're basically saying:

{if "<p>Here is my test <a href="http://url.com">with a link</a>.</p>"}

As you can see, this will lead to problems due to unescaped quotes.

Instead, use :not_empty (docs).

{if {exp:stash:not_empty name="custom_sidebar_text"}}
1
  • I don't think I would have EVER figured this out. Thanks!
    – kmgdev
    Jan 26, 2016 at 21:42

Your Answer

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

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