Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

conditional includes


4 Posts   1299 Views


17 August 2009 at 2:35am Community Member, 36 Posts

How can I use an include so that it only appears on a certain page.

I am using $layout to call my HomePage information as well as all the others however in a different area of the html altogether I need to include a footer that will only show when viewing the homepage. However I can't put it in the HomePage file as it would mess with my layout.

I have been trying this:

   <% if HomePage %>
<% include Footer %>
<% end_if %>

but it is not working. How can I get this working?
Thanx in advance


17 August 2009 at 9:19am Forum Moderator, 5511 Posts

This should work as long as you have a function HomePage which returns true / false if its on the homepage or not. For example if you want to use your html you would need a function like

function HomePage {
return ($this->URLSegment == "home") ? true : false;

Otherwise you can do this in your template

<% if URLSegment = home %>
<% end_if %>


17 August 2009 at 11:51am Community Member, 243 Posts

Yes, that is one way of doing it for sure. You would require a function with the name HomePage.

However, i would use the inbuilt function ClassName (as i always have a 'homepage' page type. ClassName will return the name of the class, ie: Page, or HomePage, etc.

So you can either do:

function HomePage() {
return ($this->ClassName() == 'HomePage') ? true : false;


<% if ClassName = HomePage %>
<% end_if %>

I would do the second one to save on redundant code.

Hope that helps.

PS: more info @


17 August 2009 at 1:34pm Community Member, 36 Posts

That worked wonderfully thank you both.