2

I am creating a page in a Drupal website of mine so that I can use it for a custom iframe in a Facebook app. The reason for this is that Facebook uses 520 instead of 960, and I was wondering if there is a way to create a separate sub theme that would be used for a single page on my Drupal site.

3 Answers 3

1

Take a look at the ThemeKey module. From the project page:

ThemeKey allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties.

1

Why an entire new theme? You can have body classes or page templates based on node id or content type. I would use the nid to have a different page template with different markup or you can have something like:

.node-56 #container{width:520px}

or

.node-type #container{width:520px}

Look at: http://drupal.org/node/1089656 for template suggestions

0

There is a global variable $custom_theme. Set it in a module or template.php:

function masqtheme_init() {
  // url is facebook url, or referrer ... 
  // if (strpos($_GET['q'], 'facebook') !== 0)
   global $custom_theme;
   $custom_theme = 'mycouncil';
  }
}

drupal api theme

This works in drupal-6 and drupal-7. In drupal-7 if playing with global variables has bad side-effects or feels dirty use:

hook_custom_theme()

instead. This returns the name of the theme for a specific page call. Mobile sites without mobileswitch are another case where we have used this.

Printing facebook canvas is a similar problem to displaying in a modal or print version of the site. The same result can be achieved by using a specific template e.g. page--facebook--news.tpl.php. Implement hook_theme() and hook_node_view(). You copy the existing page.tpl.php and remove the 'furniture' that you don't want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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