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.

Group by Related Entry Field

August 27, 2007 6:22pm

Subscribe [1]
  • #1 / Aug 27, 2007 6:22pm

    stinhambo

    1268 posts

    Hi all,

    I’m a bit tired so I thought I’d throw this one out -

    Is it possible to group entries by a Related Entry Field?

    Basically I have the following structure -

    Matting (Weblog)
    Crain (Category)
    Vinyl Tools (Related Entry)
    Product (Entry)

    and I want to output the following -

    Vinyl Tools
    Product 1
    Product 2

    Laminate Tools
    Product 1
    Product 2

    My code at the moment is this -

    <table class="table">
    <tr>
    <th></th>
    <th>Title</th>
    <th>Product SKU</th>
    <th>Description</th>
    <th>Offsite Link</th>
    </tr>
    {exp:weblog:entries weblog="{segment_1}"}
    <tr>
    <td class="{switch="resultRowOne|resultRowTwo"}">
    {related_entries id="matting_photo"}<a href="http://{image_url}" class="thickbox">{thumb_url}</a>{/related_entries}</td>
    <td class="{switch="resultRowOne|resultRowTwo"}"><a href="http://{path={segment_1}/product/}type/{categories}{category_url_title}{/categories}/{url_title}">{title}</a></td> 
    <td class="{switch="resultRowOne|resultRowTwo"}">{if matting_sku}{matting_sku}{/if}</td>
    <td class="{switch="resultRowOne|resultRowTwo"}">{matting_description}</td>
    <td class="{switch="resultRowOne|resultRowTwo"}">{if matting_link}<a href="http://{matting_link}?keepThis=true&TB_iframe=true&height=500&width=770" class="thickbox">Product Website</a>{/if}</td>
    </tr>
    {/exp:weblog:entries}
    </table>
  • #2 / Aug 27, 2007 7:17pm

    stinhambo

    1268 posts

    Ok so I read Derek’s article and adapted my code to this -

    {exp:weblog:entries weblog="tools_categories" dynamic="off"}
        <h4>{subcat_title}</h4>
    <p>    <table class="table"><br />
        <tr><br />
        <th>Title</th><br />
        <th>Product SKU</th><br />
        <th>Description</th><br />
        <th>Offsite Link</th><br />
        </tr><br />
            {reverse_related_entries weblog="tools" orderby="date" sort="asc"}<br />
        <tr><br />
            <td class="{switch="resultRowOne|resultRowTwo"}"><br />
            {related_entries id="tools_photo"}<a href="http://{image_url}" class="thickbox">{thumb_url}</a>{/related_entries}</td><br />
            <td class="{switch="resultRowOne|resultRowTwo"}"><a href="http://{path={segment_1}/product/}type/{categories}{category_url_title}{/categories}/{url_title}">{title}</a></td> <br />
            <td class="{switch="resultRowOne|resultRowTwo"}">{if tools_sku}{tools_sku}{/if}</td><br />
            <td class="{switch="resultRowOne|resultRowTwo"}">{tools_description}</td><br />
            <td class="{switch="resultRowOne|resultRowTwo"}">{if tools_link}<a href="http://{tools_link}?keepThis=true&TB_iframe=true&height=500&width=770" class="thickbox">Product Website</a>{/if}</td><br />
        </tr><br />
            {/reverse_related_entries}<br />
        </table><br />
    {/exp:weblog:entries}

    But now I can’t show the related images for each entry as it already resides inside a reverse related entry… I could just leave off the image and keep it on the product detail page but I’d like a solution for future projects that may require it.

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

ExpressionEngine News!

#eecms, #events, #releases