GetSimple Support Forum
Display components in specific page only. - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Display components in specific page only. (/showthread.php?tid=2731)



Display components in specific page only. - JoeyDown - 2012-02-09

Hello,

How could I make some components display in only some pages instead of all?

Thanks.


Display components in specific page only. - Carlos - 2012-02-09

You can insert in your template something like:
Code:
<?php if (return_page_slug()=='thatpage') get_component('thatcomponent'); ?>
(replace thatpage by your page identifier (slug) and thatcomponent by your component id.)

...Or you could use the DynPages plugin.


Display components in specific page only. - JoeyDown - 2012-02-09

Thank you but I want the components to be on the sidebar, plus I have a lot of pages in my website.


Display components in specific page only. - Carlos - 2012-02-09

If you give every component the same id as their corresponding page slugs, you can insert this in the sidebar:
Code:
<?php get_component(return_page_slug()); ?>
That is, a page with slug my-page would display component with name my-page (if that component exists).


Display components in specific page only. - JoeyDown - 2012-02-09

I want to have one conponent for like twenty pages.


Display components in specific page only. - Carlos - 2012-02-09

Do those pages have something in common? (same parent page, or some string in the page slug, ...)

If not, something like
Code:
<?php
if (in_array(return_page_slug(),array(
    'slug1'
    ,'slug2'
    ,'slug3'
    // ...
    ,'slug20'
    ))) get_component('componentname');
?>
might work (not tested).


Display components in specific page only. - JoeyDown - 2012-02-09

Thank you.

Same parent actually.


Display components in specific page only. - Carlos - 2012-02-09

Then it's easier:
Code:
<?php if (get_parent(0)=='parentpage') get_component('componentname'); ?>



Display components in specific page only. - JoeyDown - 2012-02-09

Great, thanks. I figured it out and worked perfectly!!


Display components in specific page only. - leonku - 2012-02-16

my question to this topic is that how would i have a topic header in the sidebar identified as per page then the content that i want in that sidebar ?


Display components in specific page only. - JoeyDown - 2012-02-16

leonku Wrote:my question to this topic is that how would i have a topic header in the sidebar identified as per page then the content that i want in that sidebar ?
If I understood what you're asking, get the Exec-PHP plugin and put this in the sidebar component.
Code:
<?php get_page_title(); ?>