I have an article page and at the bottom I'd like to show a list of related articles. I'm using Solspace's Tag add-on to generate the list. In order to generate the list I've created a Low Variables snippet called lv_sn_related_articles where I pass in the entry id of the entry:

{exp:low_variables:parse var='lv_sn_related_articles' preparse:entry_id='{entry_id}'}

I then use this variable within the Low Variable snippet along with the Tag tags:

{exp:tag:related_entries channel="articles" entry_id="{entry_id}" orderby="relevance" status="open|featured" limit="3" sort="asc" rank_limit="5" rank_method="total_entries"}
  <li>{exp:low_variables:single var="lv_sn_article_block"}</li>

Within this snippet I have another Low Variables snippet called lv_sn_article_block which is an article block style I will use in various other parts of the site:

  <article class="ArticleBlock">
    <div class="ArticleBlock-meta">
      {categories limit="1"}<span class="ArticleBlock-category"><a href="{path=/}">{category_name}</a></span>{/categories}
    <div class="row">
      <div class="small-4 medium-12 columns">
        <a href="/article/{entry_date format='%Y/%m/%d'}/{url_title}">
          {article_hero_image}<img class="ArticleBlock-image" src="{exp:ce_img:pair src="{url}" width="500" height="281" crop="yes" save_type="jpg" allow_scale_larger="yes" quality="81"}{made}{/exp:ce_img:pair}">{/article_hero_image}
      <div class="small-8 medium-12 columns">
          <h2 class="ArticleBlock-heading"><a href="/article/{entry_date format='%Y/%m/%d'}/{url_title}">{title}</a></h2>
          <p class="ArticleBlock-byline">
            By <a class="ArticleBlock-author" href="/author/{username}">{author}</a>, <span class="ArticleBlock-dateline">{entry_date format="%M %d, %Y"}</span>
        <p class="ArticleBlock-deck">{article_lead}</p>

The problem I'm getting is that this article block does not parse. I just get the bare template tags. If I take the article block code and put it directly into the lv_sn_related_articles the tags render normally. So something is happening with the nested lv_article_block that is causing it to not parse. How can I make this work or can it?


Ah, Parse Order.

This particular issue takes place in phase #5 of the linked PDF: parsing of module and plugin tags. This works as follows:

The first {exp:-tag encountered in the template is parsed. When the tag is done, the parser starts again, parsing the first {exp:-tag it encounters then. This goes on and on until there are no more {exp:-tags left.

So, in your case, the first {exp:low_variables:parse} tag is parsed. That results in a {exp:tag:related_entries} tag. So that is parsed. Which results in X entries, and subsequently, X {exp:low_variables:single} tags. Then, one after another, each of those are parsed. But since the variables in there should have been parsed by the Related Entries tag, but that one has already been, the vars remain unparsed.

The only way around it, is to take the content of the lv_sn_article_block var, and place it directly inside the Related Entries tag. This might result in duplicate code, but with your current setup, that's inevitable.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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