I’ve got two categories - news & events - and I’m using the same template group to display both. URLS for them look like:
/news/category/latest-news/
/news/category/events/
On the index page for displaying these I’ve got:
{exp:weblog:entries weblog="news"}
{embed="includes/header" {if segment_3=="latest-news"} the_title="Latest news" {if:else} the_title="Latest events" {/if}}
{/exp:weblog:entries}
<div id="text">
<h1>Latest {if segment_3=="latest-news"} News {if:else} Events {/if}</h1>
{exp:weblog:entries weblog="news" orderby="date" sort="desc" limit="10" disable="member_data|trackbacks" rdf="off"}
<h2><a href="http://{title_permalink=news/item}">{title}</a></h2>
<p> {entry_date format='%F %j%S, %Y'}<br />
{summary}<br />
<a href="http://{title_permalink=news/item}">Read more about {title}</a></p>
<p> {paginate}<br />
{if previous_page}<br />
<a href="http://{auto_path}">Previous entries</a><br />
{/if}<br />
{if next_page}<br />
<a href="http://{auto_path}">Next entries</a><br />
{/if}<br />
{/paginate} <br />
{/exp:weblog:entries} <br />
</div><br />
<div id="sidebar"><br />
<div class="inner"><br />
{if segment_3=="latest-news"}<br />
</p><h2>Other news</h2><p> <br />
<ul><br />
{exp:weblog:category_archive weblog="news" show="2" style="linear"}<br />
{entry_titles}<br />
<li><a href="http://{path=news/item}">{title}</a></li><br />
{/entry_titles}<br />
{/exp:weblog:category_archive}<br />
</ul><br />
{/if}<br />
{if segment_3=="events"}<br />
</p><h2>Other Events</h2><p> <br />
<ul><br />
{exp:weblog:category_archive weblog="news" show="4" style="linear"}<br />
{entry_titles}<br />
<li><a href="http://{path=news/item}">{title}</a></li><br />
{/entry_titles}<br />
{/exp:weblog:category_archive}<br />
</ul><br />
{/if}<br />
</div><br />
<div id="side-btm"></div><br />
</div><br />
{if segment_3=="latest-news"}<a href="http://{path=/news/c/events}">View events</a>{/if}<br />
{if segment_3=="events"}<a href="http://{path=/news/c/latest-news}">View news</a>{/if}<br />
{embed="includes/footer"}You can see that I’m using segment 3 to determine which category I’m in and display different info for each. But the template structure doesn’t work the same way. The template I’m using to display individual content is news/item - no 3rd segment. (At the moment the item template has the same sidebar code as the indext template and that’s the bit I’m concerned about at the moment.)
So how do I go about extracting the info that I need based on the 3rd segment on the item template if I don’t actually have a 3rd segment? Or is there a better way to put this together?