Forum
Can I have a <perch:related> nested in a <perch:related> ?
I have two collections: Publications and Authors. Some Publications have multiple authors so I setup a relationship from Publications to Authors.
I'd like to add at the end of each publication a list of related hand picked publications that might interest the reader. So I setup another relationship from Publications to Publications.
And here's where I'm stuck: I can easily output the related publication's title, date, etc… but I can't figure out how to display the list of authors.
<perch:if exists="story_related">
<h2>Other stories that might interest you</h2>
<div class="stories">
<perch:related id="story_related" collection="Publications">
<a href="/stories/<perch:content id="story_slug" type="slug" />">
<h3 class="article-title"><perch:content id="story_title" type="smarttext" /></h3>
<p class="article-author">by
<perch:related id="story_author" collection="Authors">
<perch:content id="author_firstname" /> <perch:content id="author_lastname" /><perch:if id="perch_item_rev_index" match="eq" value="2"> & <perch:else /><perch:if exists="perch_item_last"><perch:else />, </perch:if></perch:if>
</perch:related>
</p>
</a></div>
</perch:related>
The author name displayed is the one of the primary item and not those of the related one. Any idea?
Does the
story_author
relationship show anything at all? This is unchartered.Yes, it does. It shows the
author_firstname
andauthor_lastname
of the current publication (primary item) not of the related publications.I tried using
story_related.story_author.author_firstname
syntax, but nothing is displayed.I think this is probably not possible right now.
Thanks Drew.
No problem, I'll find another way around (with a callback function or something). It was elegant to process it all in the template ;)
Yes, I'd absolutely like to make this possible if we can do it without vanishing down the rabbit hole.