3

I am not sure if I have been staring at the screen too long today or what but I am having a major lapse in brain power. Here's the deal:

  • I have a list of images that I relate to specific entries
  • I use a reverse_related_entries tag to display the images on the related entry
  • If an image does not have an entry associated with it I want to randomly pull an image from the images channel and display it on the entry view.

Here is the interesting issue. The {stash:embed} (that is commented out below) gets rendered in the "no_reverse_related_entries" tag (when uncommented) but the normal EE {embed} does not render if there aren't any reverse related entries.

{exp:channel:entries
  channel="ch_pages"
  status="open"
  limit="1"
  {global:param_disable_default}
}

  {reverse_related_entries
    channel="ch_page_header_images"
    status="open"
    limit="1"}

    {if no_reverse_related_entries}
      {embed="test/random_header_image"}
      {!-- {stash:embed:includes:em_random_header_image} --}
    {/if}

    <img src="{cf_header_image:medium}" alt="{title}" width="390" id="Header-Image" role="img" />
  {/reverse_related_entries}

{/exp:channel:entries}

Stash embeds, unless tweaked with the "parse_stage" parameter (and with the defaults in place), seem to be parsed like regular embeds in other area of the site (and per the Stash docs). Where am I going wrong here?

1
  • Which version of EECMS are you using, please?
    – Sobral
    Jun 23, 2014 at 3:49

1 Answer 1

0

This is an interesting colundrum! At times like these i always refer to Low's EE Parse Order Document.

I think you are right that stash embed's behave like regular embeds, but they are not parsed at the same stage of the parse order. Embeds are parsed after module tags, remember that reverse related entries and channel entries are also technically module tags.

Can I ask, your regular embed, it doesn't actually call stash inside itself does it (i.e. have you tried with simple embed with some test markup in it?) One of the things that sticks in my head is this line from the Stash GitHub homepage :

Stash variables that you create are available to templates embedded below the level at which you are using the tag, or later in the parse order of the current template.

Me'thinks some parsing orde investigation is needed.

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.