Reputation: 199
I'm building a Drupal site, which has 4 different themes with different theme templates.
I need to use the same Drupal database to control all the content for all 4 themes.
I setup taxonomy for each theme, so when I create content I can apply it to one of the four different themes.
The Urls need to look something like
mysite.com/theme1/node/21
And
mysite.com/theme2/node/2
Also I need to make sure
mysite.com/theme1 needs to bring up the page-front.tpl.php for that theme based on the URL
I've tried using themekey which works ok except I don't then know how to pull only content which has the applied taxonomy term for that site.
and I can't get it to work with something like this
mysite.com/theme2/node/1
Only for
mysite.com/node/1/theme2
Any ideas, or anything you can provide to point me in the right direction would be greatly appreciated.
Upvotes: 0
Views: 337
Reputation: 195
There are probably a ton of ways to do this but this is how I would do it.
You could also query stuff just like in node.module but personally I prefer using views for doing the filtering.
There might be typos and whatnot in this snippet but nothing I can see now.
A good resource: http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7
/**
* Implements hook_menu().
*
* Here we define the new frontpages as well as a node view page for all them custom themes.
*/
function example_menu() {
$items = array();
foreach (example_custom_themes() as $theme) {
// Define the front page
$items[$theme] = array(
'page callback' => 'views_embed_view',
'page arguments' => array('VIEW', 'DISPLAY', $theme), // The front page view
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'theme callback' => 'example_theme_callback',
'theme arguments' => array($theme),
);
// Define the node views
$items[$theme . '/node/%node'] = array(
'title callback' => 'node_page_title',
'title arguments' => array(1),
'page callback' => 'views_embed_view',
'page arguments' => array('VIEW', 'DISPLAY', $theme, 1), // The node view display
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'theme callback' => 'example_theme_callback',
'theme arguments' => array($theme),
);
}
return $items;
}
/**
* Returns an array of the machine named custom themes.
*/
function example_custom_themes() {
return array('theme1', 'theme2');
}
/**
* Does nothing but return the theme name
*/
function example_theme_callback($theme) {
return $theme;
}
/**
* Check if the url matches the front page of a theme. If so, suggest front template.
*/
function example_preprocess_page(&$variables) {
if (in_array(arg(0), example_custom_themes()) && is_null(arg(1))) {
$variables['theme_hook_suggestions'] = 'page__front';
}
}
Upvotes: 1