0

I'm using Panel Nodes for a layout, one of which is a specialized layout that will change the overall theme design (Namely hiding the header and footer).

However, I cannot seem to find a way to detect what the current layout being used is -- at least with Panel Nodes (panels_page_get_current() works only with Panels Pages, not Panels Nodes). See: http://groups.drupal.org/node/12565

Anyone have a clue how to detect whether a specific layout is being used by Panels -- and then, preferably, pass that on to theme suggestions?

Thanks!

  • You have multiple panels nodes, and on one of them, you want the layout to be different? I don't quite get it, why don't you just use a different layout for that PN? – Letharion Nov 2 '12 at 16:16
  • It's not the layout itself that changes -- it's the theme design, namely with regards to CSS. The issue is related to styling things based on which layout is selected, but above the panelled area (I.e., in the header). If it was within the panelled area, I could just use the class given by Panels. – aendrew Nov 2 '12 at 16:39
  • Hmm, can you switch (or just use) Panels Everywhere layout then, based on a node-context? – Letharion Nov 3 '12 at 13:55
  • Nah, the entire site was built with Panel Nodes. I've since switched to Panelizer for all new sites, which works a lot better for stuff. I even had a snippet returning the name of the exact panels layout when using Panelizer, but that seems to not have saved... Hmm. I'll repost it on Monday when I'm back at work. – aendrew Nov 4 '12 at 15:23
4

The function panels_get_current_page_display() is what you're looking for:

$panel = panels_get_current_page_display();
$layout = $panel->layout;
0

This is one possible idea suggested by a co-worker. It's not very elegant, but it works.

That said, there has to be a better way of doing this. Leaving question open in case anyone has a better solution.

function sitedesign_preprocess_html(&$variables) {

/** 
 *  This outputs the markup for the node as one big string and searches for the existence 
 *  of a unique class specified in the Panel layout settings.
 *
 */
$var_txt = (string) print_r($variables['page']['content']['system_main']['node'], true); 

  if (strpos($var_txt, 'panels-flexible-content_page_main_middle')!==false) {
    $variables['classes_array'][] = 'panels-flexible-content_page_main_middle';
  }

}

Worth noting: This does NOT work with Panelizer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.