Hi all,

I'm working on a site (it's on a local server so I can't show it at this time) with Drupal 7.14 and a subtheme based on Corolla (Adativetheme). All is going great, but I need to apply a particular behavior to some pages.
All pages have first (left) and second (right) sitebar, I set all of them for responsive layouts, all's ok.
But I have a few of pages with large node content, so I need to hide the sidebars for those page and to extend the main width to 100%. I think the better way is to set a taxonomy term (for example "is_large") for those "large" nodes and show/hide the sidebars based on the assignement of that term to the node.
I agree it is possible to call the function

field_get_items('node', $node, 'TAXONOMY_NAME')

in page.tpl.php
Then if the term "is_large" is NOT in the array I can show the sidebars:

print render($page['sidebar_first']);
print render($page['sidebar_second']);

Is this the right way? I think this is better (in term of resources use) than create a db query, isn't it?
There is a smarter way using adaptive subtheming? My target is the least resource consuming solution.

Thank you all,
Franco

Comments

capitolium’s picture

Issue summary: View changes

(typo error)

capitolium’s picture

My first workaround, the file is template.php
I assume to have always 2 sidebars. I need to hide all of them on some pages with a specific vocabulary term:

function MY_SUBTHEME_preprocess_html(&$vars) {
.........

  if (arg(0) == 'node') {
  	$nid = arg(1);
  	$node = node_load($nid);
    if ( $node != "" ) {
  	  $termids = field_get_items('node', $node, 'field_barre_laterali');
        if (array_search('112', $termids[0]) == "tid") { // 112 = no sidebars
	      $barre = array_search('two-sidebars', $vars['classes_array']);
	      unset($vars['classes_array'][$barre]);
	      $vars['classes_array'][$barre] = "no-sidebars";
      }
    }
  }
}

Last, simply set:

body.no-sidebars div.sidebar {display: none;}

in MY_SUBTHEME css file.
Any better, smarter, more efficent way to do it?

Thankyou,
Franco

PedroMiguel’s picture

you can use context ( http://drupal.org/project/context/ ) to disable regions based on what you want.

capitolium’s picture

Yes PedroMiguel, but it is in beta for D7. Is it stable enought?
Moreover, I suppose using functions reduces elaboration time compared with modules (is it right, Jeff?).

PedroMiguel’s picture

I use context on at least 6 production projects, I use for a lot more than just unset regions, instead I use to the blocks only appear on some "contexts", to set http headers and a lot of more stuff. So I must say yes, is stable enough.

And yes every singe module raise execution time, every a blank space on a php file increase.

PedroMiguel’s picture

Issue summary: View changes

fix typo: dative -> adaptive

mattbloomfield’s picture

Issue summary: View changes
Status: Active » Closed (outdated)