ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Limit or count on related/reverse related entries

September 09, 2008 4:11pm

Subscribe [3]
  • #1 / Sep 09, 2008 4:11pm

    timkelty

    177 posts

    Is there any way, with php or otherwise, to effectively set a limit on related/reverse_related entries?

    Limit isn’t available as a param, so I tried to work around:

    {related_entries id="this_id"}
    {if count == "1"}{title}{/if}
    {/related_entries}

    ...but it appears count isn’t available/reset in the related loop either, it just kicks out the same count for the entries tag.

    I am finding the lack of parms on relationship tags severely limiting!

    Anybody have any solutions or ideas?

  • #2 / Sep 09, 2008 5:33pm

    Ingmar

    29245 posts

    I suppose you could always use your own PHP counter. AS you have seen, {count} is not an option, though. You might want to make this a feature request, perhaps? Moving to Howto.

  • #3 / Sep 09, 2008 7:48pm

    stinhambo

    1268 posts

    You can use PHP to create a variable -

    <?php $counting = 0; ?>
    
    {related_entries id="this_id"}
    <?php $counting ++ ?>
    <?php if ($counting == 1) { echo '{title}'; } ?>
    {/related_entries}

    My PHP is a bit rusty but I think this is right.

  • #4 / Sep 10, 2008 9:31am

    timkelty

    177 posts

    Just what I was looking to do, just didn’t have the PHP in me. Thanks stinhambo.

  • #5 / Sep 10, 2008 6:19pm

    stinhambo

    1268 posts

    No problems Tim 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases