We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Create dynamic navigation to different templates.

How Do I?

deswork's avatar
deswork
93 posts
8 years ago
deswork's avatar deswork

Hi,

At the minute I’m using a single entry page to display content from a channel within a template group.

On the template page I’m using the titles of the entries as a navigation list.

For example, I have a channel called “About”. Within about I have created 6 entries (listed below).

Signup
Leasing
Contact
Commercial
Customer Services
Find Us

I’m using the code below to create a navigation list linking to the about template.

<ul>{exp:channel:entries channel="about" dynamic="no" disable="categories|member_data|pagination"}
     <li><a href="http://{url_title_path=" class="selected">{title}</a></li>
{/exp:channel:entries}
</ul>

What I would like to do is change the template certain entries use. Take the “Find us” page I’d like to link that to a different template with the “About us” template group.

Could anyone point me in the right direction on how to achieve this?

Thanks.

       
travisb's avatar
travisb
171 posts
8 years ago
travisb's avatar travisb

You could just write different links based on which entry is being output. Like:

<ul>
 {exp:channel:entries channel="about" dynamic="no" disable="categories|member_data|pagination"}
  {if url_title == "find-us"}
   <li><a href="http://{url_title_path=%27about-us/your-different-template%27}" class="selected">{title}</a></li>
  {if:else}
      <li><a href="http://{url_title_path=%27some-segment/another-segment%27}" class="selected">{title}</a></li>
  {/if}
 {/exp:channel:entries}
</ul>

There are a lot of ways to output the urls themselves, check the variables available in channel entries: https://docs.expressionengine.com/latest/channel/channel_entries.html#single-variables

(Well the code is being botched in the above example.

1st link: href="{url_title_path='about-us/your-different-template'}"
2nd link: href="{url_title_path='some-segment/another-segment'}"
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.