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 in navigation

April 13, 2010 8:42am

Subscribe [2]
  • #1 / Apr 13, 2010 8:42am

    tomwgf

    43 posts

    This:

    <ul>
    
    {exp:weblog:entries weblog="projects" disable="custom_fields|member_data|pagination|trackbacks" sort="asc" orderby="entry_id" dynamic="off" }
    
    {if no_related_entries}
    
    {if:else}
    
    <li><a href="http://{title_permalink=" title="{title} {tagline}">{title}</a></li>
    
    {reverse_related_entries}
    
    <ul>
    
    {if select_project == "James West Space Telescope"}
    
    a
    
    {if:else}
    
    b
    
    {/if}
    
    </ul>
    
    {/reverse_related_entries}
    
    {/if}
    
    
    
    {/exp:weblog:entries}
    
    </ul>

    produces this navigation:
    -James West Space Telescope
      -b
    -Herschel Space Observatory
      -b
    -Planck Satellite
    -Scuba 2 Camera
    -Near Cam
    -Spire

    What i want it to produce is this:
    -James West Space Telescope
      -Near Cam
    -Herschel Space Observatory
      -Spire
    -Planck Satellite
    -Scuba 2 Camera

    Near Cam and Spire entries have a relationship field selected - choosing their parent entries.
    So what i hope to do is only show entries that have no relationship as main navigation, and then show their related entries underneath the parent entry.

    I know that this is easy to do with categories and parents but this way i get to produce SEF urls like: projects-applications/james_west_space_telescope/near_cam.

  • #2 / Apr 13, 2010 1:08pm

    tomwgf

    43 posts

    OK, fixed.
    Navigation now look like this:
    James West Space Telescope
    - Near Cam
    - Near Spec
    Herschel Space Observatory
    - Spire
    Planck Satellite
    Scuba 2 Camera

    <ul>
    
    {exp:weblog:entries weblog="projects" disable="custom_fields|member_data|pagination|trackbacks" sort="asc" orderby="entry_id" dynamic="off" status="Main"}
    
    <li><a href="http://{title_permalink=" title="{title} {tagline}">{title}</a></li>
    
    
    
    {reverse_related_entries}
    
    <ul>
    
    <li><a href="http://{title_permalink=" title="{title} {tagline}">{title}</a></li>
    
    {if no_reverse_related_entries}
    
    {/if}
    
    </ul>
    
    {/reverse_related_entries}
    
    
    
    
    {/exp:weblog:entries}
    
    </ul>

    i set up a new status for weblog ‘Projects’ called Main. Then changed the status of the main entries to Main.

    I also had to change the page template to allow for main & open - status=“Main|open”.

    Seems to work so far.

    It is slightly annoying that the each sub entry is within its own ul. but i suppose its not a really bad problem.

  • #3 / Apr 13, 2010 1:13pm

    tomwgf

    43 posts

    revised to this:

    <ul>
    
    {exp:weblog:entries weblog="projects" disable="custom_fields|member_data|pagination|trackbacks" sort="asc" orderby="entry_id" dynamic="off" status="Main"}
    
    <li><a href="http://{title_permalink=" title="{title} {tagline}">{title}</a></li>
    
    <ul>
    
    {reverse_related_entries}
    
    <li><a href="http://{title_permalink=" title="{title} {tagline}">{title}</a></li>
    
    {/reverse_related_entries}
    
    </ul>
    
    {/exp:weblog:entries}
    
    </ul>

    same result, a bit tidier, though now each line has a blank ul in it.

  • #4 / Apr 13, 2010 4:23pm

    Ingmar

    29245 posts

    Thanks for getting back to us. Just to make sure, you’re all good now, up and running?

  • #5 / Apr 13, 2010 4:26pm

    tomwgf

    43 posts

    yes thanks!
    i mean it could be better but it works and thats fine.
    thanks for asking
    tom

  • #6 / Apr 13, 2010 4:31pm

    Ingmar

    29245 posts

    Glad to hear that. Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases