Category: Drupal

Drupal, PHP

Show all errors while developing in Drupal

Add the following lines to your local drupal site’s settings.php. error_reporting(-1); $conf[’error_level’] = 2; ini_set(’display_errors’, TRUE); ini_set(’display_startup_errors’, TRUE);error_reporting(-1); $conf[‘error_level’] = 2; ini_set(‘display_errors’, TRUE); ini_set(‘display_startup_errors’, TRUE);

Drupal

Drupal – Render region content

If the name of our custom region is header_left then put the following code into your page.tpl.php: if ($page[’header_left’]): <div id="header_left"> print render($page[’header_left’]); </div> endif;if ($page[‘header_left’]): <div id="header_left"> print render($page[‘header_left’]); </div> endif; In your css file for example put the following css code: #header_left { width: 200px; height: 100px; float: left; }#header_left { width: 200px; …

Drupal

Installing language after installing Drupal 7

Download the language file from here. You will find a directory named translations inside the directory of your profile. for ex. standard profile: profiles/standard/translations. Move the downloaded .po file inside translations folder. Go to Modules and enable Locale module. Go to Configuration and choose Languages. Click on add languages, choose your language and save configuration. …

Drupal

Get the site base url in template.php

You can use the base_path() function. for ex. function mytheme_preprocess(&$vars) { $vars[’second_logo’] = base_path() . ‘sites/all/themes/mytheme/images/second_logo.png’; }function mytheme_preprocess(&$vars) { $vars[‘second_logo’] = base_path() . ‘sites/all/themes/mytheme/images/second_logo.png’; } base_path code: function base_path() { return $GLOBALS[’base_path’]; }function base_path() { return $GLOBALS[‘base_path’]; }

Drupal

Add javascript files in the template.php – Drupal 7

In template.php function theme-name_preprocess_html(&$variables) { $options = array( ‘group’ => JS_THEME, ); drupal_add_js(drupal_get_path(’theme’, ‘theme-name’). ‘/script.js’, $options); }function theme-name_preprocess_html(&$variables) { $options = array( ‘group’ => JS_THEME, ); drupal_add_js(drupal_get_path(‘theme’, ‘theme-name’). ‘/script.js’, $options); }

Drupal

Drupal 7 default regions

Default regions for Drupal 7 regions[header] = Header regions[highlighted] = Highlighted regions[help] = Help regions[content] = Content regions[sidebar_first] = Left sidebar regions[sidebar_second] = Right sidebar regions[footer] = Footerregions[header] = Header regions[highlighted] = Highlighted regions[help] = Help regions[content] = Content regions[sidebar_first] = Left sidebar regions[sidebar_second] = Right sidebar regions[footer] = Footer You can override the values …

Drupal, MySQL

Reset Drupal’s theme using MySQL

If you have broken everything by renaming, editing or removing the default theme and you have trouble signing in to administration panel then in this case you can fix the problem by changing Drupal’s default theme in MySQL database. Open PHPMyAdmin or MySQL Workbench and execute the following sql queries. Set Garland theme as default: …