Nested Related Collections

  • Hello,


    I'm running Perch Runway. We have a collection for 'News Articles', and a separate collection for 'News Tags'. When creating a news article the user can relate a tag to it (similar in the way a blog post tag system works).


    When we relate the news article to a page, we are struggling to get the tags related to that news article to show. Is a nested relationship even possible?


    News Article Template:

    Code
    1. <perch:content id="newsTitle" type="text" label="News Title" title />
    2. <perch:content id="newsDate" type="date" label="Date" format="D d F y"></perch:content>
    3. <perch:related id="newsTags" collection="News Tags" label="Tags">
    4. <perch:content id="newsTag" type="text" />
    5. </perch:related>


    News Tags Template:

    Code
    1. <perch:content id="newsTag" type="text" label="Tag Name" required title />


    Related News Template:

    Code
    1. <perch:related id="relatedNews" collection="News Articles" label="Related News">
    2. <perch:content id="newsTitle" type="text" />
    3. <perch:content id="newsDate" type="date" />
    4. <perch:related id="newsTags" collection="News Tags" label="Tags">
    5. <perch:content id="newsTag" type="text" />
    6. </perch:related>
    7. </perch:related>


    It's this nested tag relationship for "newsTags" we cannot get to show. The tags show perfectly fine with a normal collection call.

  • Hi Tony


    You can't nest related tags. You don't need the first related pair as you should already have that data available from your collection call at the page level – but I can't see that to be sure. I would probably want to perform a second collection call in the page template and match on the related tags (if any).


    I wonder if, in this case, using categories would be a more convenient way of approaching this if all you are doing in the second collection is adding tags and filtering on them? Collection relationships are more suited for something like authors and books where each collection has its own independent taxonomy.


    See the relationship docs right at the bottom of how to filter on related collections.


    Jon

  • Thanks Ellimondo,


    I've tried categories but have kind of ended up in the same place:


    Article Template:

    Code
    1. <perch:content id="newsTitle" type="text" label="News Title" title />
    2. <perch:content id="newsDate" type="date" label="Date" format="D d F y"></perch:content>
    3. <perch:categories id="newsCategories" label="Categories" set="news-categories">
    4. <a href="/category/<perch:category id="catPath">"><perch:category id="catTitle"></a>
    5. </perch:categories>


    Related Template:

    Code
    1. <perch:related id="relatedNews" collection="News Articles" label="Related News">
    2. <perch:content id="newsTitle" type="text" />
    3. <perch:content id="newsDate" type="date" />
    4. <perch:categories id="newsCategories" set="news-categories">
    5. <a href="/category/<perch:category id="catPath">"><perch:category id="catTitle"></a>
    6. </perch:categories>
    7. </perch:related>


    The categories show fine when a normal collections call, however they are not visible when the related news is displayed on the homepage?


    My target is:


    Create News Article with 'Tags' - relate news article to a page and have tags show on the page alongside article.