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.

Related Entries Help!

July 30, 2013 2:29pm

Subscribe [1]
  • #1 / Jul 30, 2013 2:29pm

    AirWatch

    26 posts

    Hi! I have a unique situation where I think I need related entries as opposed to categories. However I’m new to related entries and I’m trying to wrap my head around that concept and eventually find the best approach.

    Guidance will be appreciated!

    This is how my content is organised:

    1. Categories
    a. Browser
    b. OS

    2. Vendors
    a. Apple
    b. Google

    3. Products
    a. Safari
    b. iOS (lets assume apple creates only one OS)
    c. Chrome
    d. Android OS

    The Vendors can belong to multiple categories - Apple creates Browser and OS.
    In this scenario, if I go the category route, I can create Browser and OS as two categories but cannot create Apple as sub-categories of both (URL conflicts).

    So this is how it should work on the front end.
    Scenario:
    1. User clicks on othe OS category
    2. A page displays all the Vendors who create an OS - Apple and Google would be listed.
    3. User clicks on Apple - a page displays a brief description on Apple and the OS it creates. It should not list Safari - just the OS because that’s the path the user took.

    So the potential URL would be site.com/os/apple/ios

    Like wise, if the user clicks on Browser - Apple and Google will be listed, user clicks on Google, and then Chrome would be listed.

    Template Code:

    Main page that lists out all the categories:

    <ul>
    {exp:channel:categories category_group_id="1"}
    <li>
     <a href="/{category_url_title}">{category_name}</a>
    </li>
    {/exp:channel:categories}
    </ul>

    User clicks on one of the categories and is taken to the Vendor page

    <h3><a href="/">Home</a></h3>
    <p><ul><br />
    {exp:channel:entries channel="vendors" category="{segment_1_category_id}" dynamic="no"}<br />
    {if no_results}<br />
      {redirect="messages/404"}<br />
    {/if}<br />
     <li><a href="/{segment_1}/{url_title}">{title}</a></li><br />
    {/exp:channel:entries}<br />
    </ul>

    User, clicks on a Vendor and the product page displays:

    {exp:channel:entries channel="vendors" category="{segment_1_category_id}" url_title="{last_segment}" limit="1" dynamic="no"}
    {if no_results}
      {redirect="messages/404"}
    {/if}
    {vendor_description}
    
    <!-- Trying to relate the product to the vendor here -->
    
    <!-- Perhaps reverse related? -->
     {apps}
      <h3>{apps:title}</h3>
    <p>  {apps:app_description}<br />
     {/apps}<br />
    {/exp:channel:entries}

    This displays all the products of that vendor - so when the user clicks on Apple, it displays Safari and iOS.

    url: site.com/os/apple/iOS -> should not display safari.

    Any guidance/best practice on how to approach this would be great.

    Thanks!

  • #2 / Aug 02, 2013 6:35am

    Giraffentoast

    152 posts

    Channel OS
    - Android OS
    - iOS

    Channel Browsers
    - Chrome
    - Safari

    Channel Vendors
    - Apple
    - Google

    ——————-

    Now, every entry in OS and Browsers gets a relationship with 1 entry from Vendors.

    /os/ -> all entries from channel Vendors
    /browsers/ -> same

    /os/apple/ -> data from entry Apple plus data from related entry iOS
    /os/google/ -> data from entry Google plus data from related entry Android OS

    This is perfectly possible with categories as well.
    What was your question…?

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

ExpressionEngine News!

#eecms, #events, #releases