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.

Total Reverse-Related Entries

October 29, 2007 11:18pm

Subscribe [3]
  • #1 / Oct 29, 2007 11:18pm

    PXLated

    1800 posts

    This is somewhat related to this thread.
    —————

    Scenario: The clients blog posts can have 0-10 images. The images are ancillary to the text so displaying any more than 2-3 overwhelms the text. Since I can’t do what I wanted in the above link, I’ve hardwired the number of images brought in through the reverse_related entries tag. If there are more than that hardwired number, I want to include a link to a gallery showing all the images with their captions. The images are in their own weblog as single entries.

    Need: Have to get the total number of images in the gallery weblog that are related to the currently displayed entry and condition this against the display limit. Something like this…

    {reverse_related_entries weblog="w_gallery" orderby="date" sort="asc" limit="3"}
    {image}
    {caption}
    {if current_count == "3" AND current_count < total_related_entries }
    Here’s a link to the image gallery for this post.
    {/if}
    {/reverse_related_entries}

    Have searched but couldn’t find if there’s variables that will work or can do this.
    Any insights will be greatly appreciated.

  • #2 / Oct 31, 2007 2:04am

    PXLated

    1800 posts

    Ya, me bad…B U M P
    ———
    Is there a way to do this conditional and get the total entries I need…Query, PHP, standard EE, anything?

  • #3 / Nov 01, 2007 12:39am

    Lisa Wess

    20502 posts

    According to the docs, nearly any of the weblog entries variables can be used; so why not just use count and total_results?

  • #4 / Nov 01, 2007 1:19am

    PXLated

    1800 posts

    Those give the count or total that are being brought in for display (the limit), not the grand total that are related. Or, at least that’s the way they’ve worked in my testing code.

  • #5 / Nov 01, 2007 1:59am

    PXLated

    1800 posts

    Derek…I need the total related entries. The total_results, as I’ve tried it, gives me the total for the results returned as set by the limit parameter. If my limit is set to 3 and there are 10 images related to the entry, the total_results has given me 3. I need the 10.
    Make sense?

  • #6 / Nov 01, 2007 2:07am

    Derek Jones

    7561 posts

    Ok, yes, that’s clear.  You might experiment with template debugging turned on so you can see how much, if any, the memory required jumps (or execution time) if you just leave off the limit= parameter, and only display entries if the count < 3.  Then total_results will be the total number of reverse relationships, which is what you are looking for.

    {reverse_related_entries weblog="w_gallery" orderby="date" sort="asc"} 
    {if count < 4}
        {image} 
        {caption} 
        {if count == “3” AND total_results > 3} 
            Here’s a link to the image gallery for this post. 
        {/if}
    {/if}
    {/reverse_related_entries}
  • #7 / Nov 01, 2007 2:35am

    PXLated

    1800 posts

    Ahhhh yes…I can’t imagine it will be too bad as there will probably never be more than 10-15 related entries for any post but I’ll check. Thanks Derek!

    Ultimately I also want to use a field from the weblog so the editor can set the limit based on length of post but that requires a different parse order. Mentioned it to Paul a while back.

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

ExpressionEngine News!

#eecms, #events, #releases