Components Depending On The Page

If you would like a component to be displayed on only one page, that can be done by adding the following code to your theme's template.php file:

<?php if (return_page_slug()=='PAGE') get_component('COMPNAME'); ?>

Don't forget to replace PAGE with your page's slug and COMPNAME with the component's name.

Components Depending On The Parent Page

Now If you want a component to be displayed on pages of a specific parent page, you can do it in a similar way:

<?php if (get_parent(0)=='PAGE') get_component('COMPNAME'); ?>

Again, don't forget to replace PAGE with your page's slug and COMPNAME with the component's name.

Exluding components

If you would like to exclude a component from a page you could do that by replacing==” with “!=” in the code above.

 
components-depending-on-the_page.txt · Last modified: 2012/02/08 18:21 by HelloWorld