Hy!
Altough key in hook_menu is 'page callback', it does not mean page.tpl.php. Rather you're changing content for <?php print render($page['content']); ?> inside page.tpl.php
You could use hook_theme_registry_alter to change the location of this template. function mymodule_user_dashboard_theme_registry_alter(&$theme_registry) { $path = drupal_get_path('module', 'mymodule_user_dashboard');
// Alter the path for page.tpl.php if (isset($theme_registry['page'])) { $q = explode('/', $_GET['q']); if ($q[0] == 'dashboard') { $theme_registry['page']['path'] = $path . '/templates/dashboard'; } } }
Note that dashboard in $theme_registry['page']['path'] = $path . '/templates/dashboard'; is a folder. I don't know how to change template name here. Don't think it's really needed either.
Does this help?
-- Hannes
On Mon, Sep 10, 2012 at 3:00 PM, themes-request@drupal.org wrote:
Send themes mailing list submissions to themes@drupal.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.drupal.org/mailman/listinfo/themes or, via email, send a message with subject or body 'help' to themes-request@drupal.org
You can reach the person managing the list at themes-owner@drupal.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of themes digest..."
Today's Topics:
- Replicating page.tpl.php in D7 (Jeff Greenberg)
---------- Forwarded message ---------- From: Jeff Greenberg listmail.ayendesigns@gmail.com To: Themes themes@drupal.org Cc: Date: Sun, 9 Sep 2012 19:13:33 -0400 Subject: [themes] Replicating page.tpl.php in D7 I have the following code in my module in D7. My intention is to have my custom template loaded in place of page.tpl.php for this specific page, and to have the template file in the module directory rather than having page--mypage.tpl.php in the theme directory.
The problem I'm running in to is that after the template is loaded, it complains that none of the page variables (logo, etc) exist. I realize that my arguments array is empty in the code, but in looking around (in all the wrong places, apparently) I can't figure out what to pass.
function mymodule_user_dashboard_menu() { $items = array();
$items['dashboard/%user_uid_optional'] = array( 'page callback' => '_mymodule_user_dashboard_template', 'page arguments' => array(1), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, );
return $items; }
function _mymodule_user_dashboard_template() { return theme('mymodule_user_dashboard_template'); }
function mymodule_user_dashboard_theme() { $themes = array( 'mymodule_user_dashboard_template' => array( 'template' => 'templates/dashboard', 'arguments' => array(), ) );
return $themes; }
--
drupal.org/user/367108 linkedin.com/in/jeffrgreenberg accidentalcoder.com / ayendesigns.com @accidentalcoder
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes