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

Support archive

Variables not working for comment previews

James 9 Sep 2011 08:23 question, complete

Hello,

Does anyone know why a variable I’m using to hold a snippet of code might not work for comment previews.

For reference, it has early parsing and the code’s fairly simple and works fine on all other pages, it looks something like this:

{if image_matrix} 
{image_matrix}
<img src="{image}" />
{/image_matrix}
{/if}

Any help appreciated, thank you.

Replies

  1. Low 9 Sep 2011 08:26

    Hi James,

    I take it {image_matrix} is the variable? What is its variable type? Assets?

  2. James 9 Sep 2011 08:32

    That was quick Low, thanks.

    No sorry, that’s just the code that’s used inside the variable. It’s just a textarea I’m using rather than using snippets.

    I should also add the variable is inside the channel:entries tag not the comment:preview, and I’m running a local install of 2.2.1.

  3. James 9 Sep 2011 09:30

    UPDATE

    The variable is being parsed and actually does appear to be working. This appear to be a problem more to do with the Matrix field inside the variable.

    Apologies for the confusion.

    Any pointers as to what might be happening here are still very welcome though, the code outside of the variable works, i.e. if I cut and paste what’s in the variable directly in to the template.

  4. Low 9 Sep 2011 09:44

    James, do you have the complete template code available? I think I need to see some more context for this.

  5. James 9 Sep 2011 09:47

    Sure, I’ll send you an email though if that’s okay, rather than post it all here.

  6. Low 9 Sep 2011 09:48

    Sure, no problem. hi at gotolow dot com.

  7. James 9 Sep 2011 15:11

    Thanks for taking a look Low,

    I can confirm it works fine with snippets, that’s what I’ve reverted back to for now.

    Another thing that’s strange is, if I make the preview template the current template (the one sending the initial form) I get a slightly different result, the Matrix tags actually show in the markup/page as not parsed, although everything else works fine. So, it definitely looks like a problem with Matrix tag pairs via LV only when a comment preview has been requested.

  8. Low 9 Sep 2011 15:39

    Wait, so with a Snippet the page works, but as an early parsed LV it doesn't?

  9. James 9 Sep 2011 16:00

    Yep, that’s what it looks like.

    Just tested it again with exactly the same code in a snippet {snp_images}, next to a LV {lv_images} with early parsing, and only the LV fails on previewing a comment.

  10. Low 9 Sep 2011 16:04

    How queer. Can you turn on template debugging and load up the template. Look for the array of snippet keys and values. Can you see the LVs with early parsing in there?

  11. James 9 Sep 2011 16:13

    Yep, I can see the LVs in the snippet keys.

  12. Low 12 Sep 2011 13:49

    Take another look. When not previewing the comment, you *can* see the snippets, but when previewing, you *cannot*.

    It seems the sessions_end extension hook is skipped when previewing comments. That's why Low Variables cannot add the early parsed global variables to the snippet array. Can't really work around that, except using a native snippet, like you're already doing.

  13. James 12 Sep 2011 14:14

    Apologies, yep that was me being stupid. I had some ajax loading in another template I was mistaking those snippets for. Thanks for taking a look and confirming, much appreciated.