3

On our web-site each article (Single Entry Page) is accompanied by 4 related articles. Those 4 are chosen by the editors. I set up a native EE 2.6.1 Relationships Field for them. For the article itself I set up a Content Elements Field. In the related articles are below the main article I´d like to show

  1. the title of the related articles
  2. the articles first image (called intro_image)
  3. I also need the url_title_path, to make title + image clickable.

I have no problems with title + url, but can´t get the CE tag to work.

This is my code

    {exp:channel:entries channel="article" status="open|featured"}
       {related_article status="not closed"}
          {artikel}
            {gallery}
              {if element_name=="intro_image"}
                 {images}
                    {related_article:image} <= doesn´t work!
                 {images}
              {/if}
            {/gallery}
          {/artikel}
          <p><a href="{related_article:url_title_path='artikel/index'}">
{related_article:title}</a></p>
      {/related_article}
    {/exp:channel:entries}

This code is working fine for the title and the URL, but not for the image. I tried to prefix {artikel}, {gallery}, {image} in various combination with {related_article:}. But this is not working. When I leave out the related_article in frot of each of the three tags, I get the intro image from the main article. So I need an identifier, that points to the child entry.

1 Answer 1

1

First off, your {images} tag is duplicated - instead of closing the first tag with {/images}, you have another {images}. Dunno if that's a simple typo from simplifying the actual template or not.

Secondly, is the {if element_name=="intro_image"} code getting called at all? I've found that such conditionals never work for me. I have to wrap element_name in quotes and EE tags: {if '{element_name}' == "intro_image"}. You can insert some temporary code in the conditional to make sure that part is working at least:

          {if '{element_name}'=="intro_image"}
             {!-- Debug code --}
             Element name is "intro_image"!
             {!-- // Debug code --}
             {images}
                {related_article:image} <= doesn´t work!
             {images}
             --}
          {/if}

Once all that's sorted out, if you still have problems, let me know. :)

EDIT: And yes, I know this is a rather old question, but Google sent me here! :p

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.