Page 1 of 1
Combining 2 similar templates into 1 template
Posted: Wed Dec 07, 2011 9:59 pm
by DoctorWho
I have two templates on my site with the only difference being the left-hand side bar.
Template A displays the upcoming events, while
template B displays all of the child object in the parent category.
Is it possible to combined these template into one template with an if statement to determine what is displayed?
Something like:
Code: Select all
if current page is child
then
{menu start_level="2" collapse="1"}
else
{cms_module module="CGCalendar" display="upcominglist" limit="12" unique_only="0" category="general"}
Re: Combining 2 similar templates into 1 template
Posted: Wed Dec 07, 2011 10:15 pm
by Wishbone
I'm assuming that you mean that you want it to show one thing if you are in a top-level page, and show something else if you're in a lower-level page?
Install CGSimpleSmarty. Put the following in your template:
Code: Select all
{* Get name of parent and put it in $parent *}
{$cgsimple->get_parent_alias($page_alias, 'parent')}
{* If I have a parent, then I'm at a lower level *}
{if $parent}
{menu start_level="2" collapse="1"}
{else}
{CGCalendar ...}
{/if}
Re: Combining 2 similar templates into 1 template
Posted: Wed Dec 07, 2011 10:39 pm
by DoctorWho
Not just on the top-level page, but also on all of the lower-level pages.
Example:
On the
information category there are 12 lower level pages on the left-hand side bar. I would like each of objects to be displayed when a user clicks on anyone one of them. Such as history, mission statement, etc..
Then have the Upcoming Events being displayed if the user is on a top-level page that doesn't have any lower level pages. Such as the Home, and Contact page.
Re: Combining 2 similar templates into 1 template
Posted: Thu Dec 08, 2011 1:51 am
by Dr.CSS
You could use {capture} and if empty show the other content...
Re: Combining 2 similar templates into 1 template
Posted: Thu Dec 08, 2011 5:46 pm
by DoctorWho
I've revised the sudo code.
if active page (or current page) is parent
and has child
then
display the child navigation objects
else
display upcoming events
So would this work than?
Code: Select all
{$cgsimple->get_parent_alias($page_alias, 'parent')}
{if $parent}
<p id="heading">{$cgsimple->get_root_alias()}</p>
{menu start_level="2" collapse="1"}
{else}
<p id="heading">Upcoming Events</p>
{cms_module module="CGCalendar" display="upcominglist" limit="12" unique_only="0" category="general"}
{/if}