drupal-theming

Drupal 7 - How to load a template file from a module?

一曲冷凌霜 提交于 2019-12-03 16:56:31
问题 I am trying to build my own module in Drupal 7. So I have created a simple module called 'moon' function moon_menu() { $items = array(); $items['moon'] = array( 'title' => '', 'description' => t('Detalle de un Programa'), 'page callback' => 'moon_page', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK ); return $items; } function moon_page(){ $id = 3; $content = 'aa'; } in moon_page() function, I like to load a custom template 'moon.tpl.php' from my theme file. is this

Include two versions of jQuery on a page without affecting old plugins

半世苍凉 提交于 2019-12-03 07:56:34
问题 Our drupal site runs with jQuery version 1.2.1 which we have not upgraded. The problem is this: We need to add a new plugin named jQuery Tokeninput, but it's working only in latest jQuery versions. We tried adding the latest jQuery version with old version, but it produces weird results. My question is, how to include the latest jQuery file without affecting the old jQuery plugins? 回答1: Method #1: (recommended) You could do something like this: <script type='text/javascript' src='js/jquery_1

Drupal 7 - How to load a template file from a module?

心不动则不痛 提交于 2019-12-03 06:04:38
I am trying to build my own module in Drupal 7. So I have created a simple module called 'moon' function moon_menu() { $items = array(); $items['moon'] = array( 'title' => '', 'description' => t('Detalle de un Programa'), 'page callback' => 'moon_page', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK ); return $items; } function moon_page(){ $id = 3; $content = 'aa'; } in moon_page() function, I like to load a custom template 'moon.tpl.php' from my theme file. is this possible? For your own stuff (not overriding a template from another module)? Sure, you only need to:

Drupal 7: Access custom node field in page.tpl.php

狂风中的少年 提交于 2019-12-03 05:21:34
问题 I added a new field "mood" (image) to the page content type. Is there any way to access the image stored in this field in the page.tpl.php? 回答1: Should be $node = node_load($nid); $node->field_mood[$node->language][0]['value']; 回答2: There is a new "field_get_items()" function in drupal 7. The $node variable should already be defined in page.tpl so the first line may not be required. This will get the field in the appropriate language. There is also an optional parameter to specify the desired

Style Drupal 7 log-in page

谁都会走 提交于 2019-12-03 03:39:50
How do I style the login-page of Drupal 7? I used different methods like page-user-login.tpl or user-login.tpl of page-login.tpl but with no results. Is there an easy way to theme your login page in Drupal 7 in his own .tpl -file? You can override any page template by naming your templates in the following convention: For page 'user/login': page--user--login.tpl.php For page 'foo/bar/' page--foo--bar.tpl.php See Core templates and About overriding themable output for more information. Remember to clear Drupal's caches once you add a new template file so the theme registry has a chance to pick

How to insert a block into a node or template in Drupal 7?

房东的猫 提交于 2019-12-03 00:40:42
问题 In Drupal 6, it was easy to insert a block into a template with the following code: $block = module_invoke('views', 'block', 'view', 'block_name'); print $block['content']; However, using the same instructions in Drupal 7 does not seem to work. I have looked around and cannot find the new method. Does Drupal 7 have a routine that can allow for programmatically inserting a block into a template or node? 回答1: With wrburgess's answer you may get an error if your server is using a newer version

Drupal 7: Access custom node field in page.tpl.php

左心房为你撑大大i 提交于 2019-12-02 17:44:39
I added a new field "mood" (image) to the page content type. Is there any way to access the image stored in this field in the page.tpl.php? Should be $node = node_load($nid); $node->field_mood[$node->language][0]['value']; There is a new "field_get_items()" function in drupal 7. The $node variable should already be defined in page.tpl so the first line may not be required. This will get the field in the appropriate language. There is also an optional parameter to specify the desired language if needed. $node = node_load($nid); $values = field_get_items('node', $node, 'mood'); if ($values !=

Changing Drupal's theme and keeping Garland as the admin theme?

老子叫甜甜 提交于 2019-12-01 22:57:49
问题 How to apply a contrib theme to a Drupal-6 site without changing the administration theme -the contrib theme for the site and Garland for the administration interface- ? Thanks. 回答1: Go to Administer -> Site configuration -> Administration theme. There, you can set the administration theme. If you'd like additional control over the administration theme, use the Admin Theme module. 回答2: For the administrator (with UID 1), go into it's user profile (in /user/edit/1) and change the theme, but

How to implement hook_theme in drupal 7?

一个人想着一个人 提交于 2019-11-29 03:55:30
I created a new drupal 7 theme and trying to implement hook_theme at template.php like this: function mytheme_theme($existing, $type, $theme, $path){ return array( 'mytheme_header'=>array( 'template'=>'header', 'path'=>$path.'/templates', 'type'=>'theme', ), ); } then I placed header.tpl.php into templates directory and cleared all caches, and call theme function: theme('mytheme_header', $vars); and header.tpl.php likes this: <?php fb('calling header template');//the function of FirePHP to output debug info print '<div>Header</div>'; //... I check Firebug and it get the info 'calling header

How to implement hook_theme in drupal 7?

扶醉桌前 提交于 2019-11-27 18:10:19
问题 I created a new drupal 7 theme and trying to implement hook_theme at template.php like this: function mytheme_theme($existing, $type, $theme, $path){ return array( 'mytheme_header'=>array( 'template'=>'header', 'path'=>$path.'/templates', 'type'=>'theme', ), ); } then I placed header.tpl.php into templates directory and cleared all caches, and call theme function: theme('mytheme_header', $vars); and header.tpl.php likes this: <?php fb('calling header template');//the function of FirePHP to