Components specific to the page - How? - 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: Components specific to the page - How? (/showthread.php?tid=4293) |
Components specific to the page - How? - Timbow - 2013-02-12 I know I have seen somewhere how to do this but can't find the info - to have a different component on a different page without making a new page template. To be clear, what I am trying to do is to put a mini thumbnail gallery in the sidebar with i18n galleries, but on the page 'Sheep' I want the gallery of sheep, on the page 'Goats' I want the goat gallery and on Home I don't want any gallery at all; so I will have different components for the different sidebar contents, and I want them to appear on the right pages RE: Components specific to the page - How? - eatons - 2013-02-12 i think this is how you do it, ...if not, someone will chastise me! Setup a component for each and inside your sidebar template, place the following: Code: <?php if (get_parent(0)=='Sheep') get_component('Sheep'); ?> Code: <?php if (get_parent(0)=='Goats') get_component('Goats'); ?> RE: Components specific to the page - How? - shawn_a - 2013-02-12 Just use the slug in the component name when calling it. RE: Components specific to the page - How? - Timbow - 2013-02-13 Okay, so I make a page with the slug sheep Then I make a component with the slug sidebar-sheep Likewise I make a page with the slug goats Then I make a component with the slug sidebar-goats Then in my template I call the sidebar with something like <?php get_component('sidebar-get_page_slug()'); ?> But I have to do something with the brackets or quotes don't I? I found Mvlcek's instructions here: http://mvlcek.bplaced.net/how-to/sidebars/ but he has an if else thing (which is good) to use the default sidebar and he gets an i18n_component which I don't understand. also an extra .(full stop / period) . RE: Components specific to the page - How? - shawn_a - 2013-02-13 PHP Code: get_component('sidebar-'.get_page_slug()); You oly need a check function if you want to use a default if the component does not exist. RE: Components specific to the page - How? - Timbow - 2013-02-13 thanks Shawn, I must get that php course out one day. RE: Components specific to the page - How? - Carlos - 2013-02-13 PHP Code: get_component('sidebar-'.get_page_slug(false)); ...so that it doesn't echo the slug. RE: Components specific to the page - How? - shawn_a - 2013-02-13 yeah or you can use return_page_slug() PHP Code: function return_page_slug() { my bad was just copying psuedocode RE: Components specific to the page - How? - Carlos - 2013-02-13 :-) ...or my favorite: get_page_slug(0) (shorter!) RE: Components specific to the page - How? - Timbow - 2013-03-07 I am still not getting this right. I have a site with banner type header images across the tops of the pages. The homepage has a slideshow of images and the slideshow is the default unless a specific static image is assigned to a page. I have put the slideshow and the static images in components which I am calling with the following: PHP Code: <div class="banner"> Help appreciated. RE: Components specific to the page - How? - Carlos - 2013-03-08 You could use this: http://get-simple.info/forums/showthread.php?tid=3102&pid=24159#pid24159 And then change this: Code: if (get_component('banner-'.get_page_slug(false))) by: Code: if (component_exists('banner-'.get_page_slug(false))) RE: Components specific to the page - How? - Timbow - 2013-03-08 all working! Thanks Carlos RE: Components specific to the page - How? - inteltone - 2013-03-11 I didn't need to publish a component on one page of my site. So I wrote this code: Code: if( return_page_slug() == 'page1' ) { It worked! |