I have a number of relationship fields in a fluid field in a channel that is used to sort and organize articles in a magazine issue. I want to be able to, from the child entry - aka the article - find its parent so I can report breadcrumb-like information with the article back to it's issue. The issue seems to be that the child doesn't know which relationship field it falls into. I don't want to set up an additional relationship field from the article to the issue because that would require twice as much data entry. Is there a way?

From my child entry template i've tried the following to test if it can see any relationships:

{exp:channel:entries channel="article" limit="1"}

{parents}
 {if parents:count == "1"}<h3>Parents</h3>{/if}
{parents:title}
                {if parents:no_results}No parent entries{/if}
                {parents:switch="one|two"}
            {/parents}

            {siblings}
              {if siblings:count=="1"}<h3>Siblings</h3>{/if}
                {siblings:title}
                {if siblings:no_results}No sibling entries{/if}
                {siblings:switch="one|two"}
              {/siblings}

              {reverse_related_entries}
                {if reverse_related_entries:count=="1"}<h3>reverse_related_entries</h3>{/if}
                {reverse_related_entries:title}
                {if reverse_related_entries:no_results}No reverse_related_entries{/if}
                {reverse_related_entries:switch="one|two"}
              {/reverse_related_entries}

{/exp:channel:entries}

... the output was:

No parent entries No sibling entries {reverse_related_entries} {reverse_related_entries:title} {reverse_related_entries:switch="one|two"} {/reverse_related_entries} 

Clearly reverse_related_entries isn't a thing anymore. Is there a way to do this without using a relationship field in each channel that points in opposite directions? Is there a special way to glean this info when its within a fluid field?

... And now that I've written up this question it occurs to me that I could query each relationship field name fishing for results. It seems like a lot of unnecessary code but it would get the job done I would think. Any better ideas?

Update: i enabled PHP on input for the template and wrote a script to loop through all of the possible relationship field names within the fluid field. Like so:

            <?php
        $sections_list=array('1000_words','digging_deeper','feature_articles','in_review','letter_from_the_editor','reflections','reportage','talking_points','voices');
        foreach($sections_list as $section){
        ?>
        {parents field="<?php echo $section; ?>"}
        {if parents:count == "1"}<h3>Parents in <?php echo $section; ?></h3>{/if}
        {parents:title}</br>
        {if parents:no_results}No parent entries in <?php echo $section; ?><br/>{/if}
        {parents:switch="one|two"}
        {/parents}

        <?
        }
        ?>

        {siblings}
          {if siblings:count=="1"}<h3>Siblings</h3>{/if}
            {siblings:title}
            {if siblings:no_results}No sibling entries{/if}
            {siblings:switch="one|two"}
          {/siblings}

The result was that it still found no relationships in any of the field names:

No parent entries in 1000_words No parent entries in digging_deeper No parent entries in feature_articles No parent entries in in_review No parent entries in letter_from_the_editor No parent entries in reflections No parent entries in reportage No parent entries in talking_points No parent entries in voices No sibling entries

So now i'm out of ideas.

  • One further observation is that no sibling relationships are found even for the child entries that definitely are supposed to have sibling entries (because they are set in the same relationship in their parent). This must have something to do with added complexity with the fluid field. – ianumeda Sep 11 at 20:03
  • update2: i enabled PHP on input for the template and wrote a script to loop through all of the possible relationship field names within the fluid field. – ianumeda Sep 11 at 20:48
  • I suppose a question to ask before this question would be: "how do you get parent relationships through fluid fields when you DO know the field name?" – ianumeda Sep 19 at 16:51

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.