Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How about a specific components section for each page
#2
You could just name your components "home_sidebar", "contact_sidebar", "stuff_sidebar" ...
Then you can simply using if- or switch statement in your template to determine which page is actually loaded and then show corresponding component:

PHP Code:
$slug get_page_slug(false);

switch ($slug) {
    case 'home':
        get_component($slug.'_sidebar');
        break;
   case 'contact':
        get_component($slug.'_sidebar');
        break;
    case 'stuff':
    
get_component($slug.'_sidebar');
        break;


Or use a whitelist array of allowed pages:

PHP Code:
$slug get_page_slug(false);

$whitelist = array(
    
'home'
    
'contact',
    
'stuff'
);

if(
in_array($slug$whitelist)) {
    
get_component($slug.'_sidebar');

Reply


Messages In This Thread
RE: How about a specific components section for each page - by Bigin - 2016-07-20, 23:17:28



Users browsing this thread: 1 Guest(s)