0

I'm trying to set a limit to the results displayed from relationship fields:

{exp:channel:entries channel="childChannel"}
  {siblings field="relationship_field"}
    {siblings:title} - {siblings:field1} - {siblings:field2}
  {/siblings}
{/exp:channel:entries}

I'd really like to use the entry_id_to="{var}" and the entry_id_from="var" so I could split the results into two nice columns. Somthing like this

<div class="two_column_class">
<div>
    <ul class="one">
        <li>First line of text</li>
        <li>Second line of text</li>
        <li>Third line with some text</li>
        <li>Fourth line of text</li>
        <li>Fifth line with some</li>
    </ul>
</div>
<div>
    <ul class="two">
        <li>First line of text</li>
        <li>Second line of text</li>
        <li>Third line with some text</li>
        <li>Fourth line of text</li>
        <li>Fifth line with some</li>
    </ul>
</div>

I'd put the first "portion" in the first DIV, and the second, the second DIV.

But in the list of options / parameters in the manual, I don't see the entry_id_to or the entry_id_from as relationship field parameters.

Am I going about trying to solve this the wrong way?

Thanks everyone...

  • Could you clarify? Are you trying to limit your relationship field output to two entries so you can display them in a certain manner? It would be easier to help if you could modify your example HTML output to explain the connection instead of "First line of text, etc...". I'm not connecting your relationship field tags with your desired output. – jrothafer Apr 29 '16 at 15:29
  • Yes, I was going to use two sections. If the first div, I was going to use the ee entries tag, and limit the numbe of entries to {absolute_results}/2, and then do the same for the second div, but display the second set. Does that make sense? – Jake Covert Apr 29 '16 at 16:27
  • Something along the lines of: <div class="two_column_class"> <div> <ul class="one"> {exp:channel:entries channel="childChannel"} {siblings field="relationship_field" entry_id_to="{absolute_results}/2"} <li>{siblings:title}</li> {/siblings} {/exp:channel:entries} </ul> </div> <div> <ul class="two"> {exp:channel:entries channel="childChannel"} {siblings field="relationship_field" entry_id_from="({absolute_results}/2)+1"} <li>{siblings:title}</li> {/siblings} {/exp:channel:entries} </ul> </div> – Jake Covert Apr 29 '16 at 16:30
1

I've found the simplest way is to use stash like this:

{exp:channel:entries channel="childChannel"}
    {exp:stash:set_list name="related" parse_tags="yes"}<!-- Set the list -->
        {siblings field="relationship_field"}
            {stash:title}{siblings:title}{/stash:title}
            {stash:field1}{siblings:field1}{/stash:field1}
            {stash:field2}{siblings:field2}{/stash:field2}
        {/siblings}
    {/exp:stash:set_list}
{/exp:channel:entries}



{exp:stash:get_list name="related" limit="1/2"} <!-- Get list & limit to half -->
{if count == 1}
    <div>
    <ul class="one">
{/if}
    <li>{title} | {field1} | {field2}</li>
{if count == total_results}     
    </ul>
    </div>
{/if}
{/exp:stash:get_list}

{exp:stash:get_list name="related" offset="1/2"} <!-- Get list & Offset by 1/2 -->
{if count == 1}
    <div>
    <ul class="two">
{/if}
    <li>{title} | {field1} | {field2}</li>
{if count == total_results}     
    </ul>
    </div>
{/if}
{/exp:stash:get_list}
| improve this answer | |
  • This worked perfect! Although I did have to put the exp:stash:set_list tag on the very outside (Keeping exp:channel:entries inside). – Jake Covert May 1 '16 at 13:10
  • If on the same page you can use the code BUT wrap both get_list calls within {exp:stash:parse} tags. – stuartmcd69 May 1 '16 at 14:17

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.