Tag Archives: Drupal Theme

Drupal 7 – Customize the user login block

In Drupal 7, there is a user login block. We can customize that block using the hook_form_FORM_ID_alter(). You can create a custom module or implement it directly in the theme template.php.

Here is a simple example written by Liam McDermott. You can add this in the template.php and replace THEMENAME by your theme name.
Continue reading Drupal 7 – Customize the user login block

Drupal 7 – form_set_error does not show

I have a custom form and i render the form using drupal_get_form() inside the .tpl.php. One day, i find that when the submission could not pass the validation, only the failed field was highlighted but without the error message. Then i find the following post suggesting that i should called the drupal_get_form() in the .module file or preprocess function instead of the .tpl.php.
form_set_error Not displaying error after invalid form submission

So i put the drupal_get_form() call in the preprocess function and set the form in the $vars so it could be printed in the .tpl.php. But that still could not solve the problem. Finally i come up with a simple solution which is just adding the following line in the .tpl.php.

<div><?php print theme_status_messages(array('display' => 'error')); ?></div>

 

Done =)

Reference:

Drupal 7 – Override the Facebook Connect login button theme

We can implement Facebook Login using Facebook Connect. For more info, please refer to
Drupal 7 – Allow Facebook login using Facebook Connect

For those who wants to override that Facebook Login template, add the following function in your theme template.php and and customize it as u wish.
Continue reading Drupal 7 – Override the Facebook Connect login button theme

Drupal 7 – Customize region template file for specific content type

We can add preprocess function for regions such that we can add customization before rendering the region template file(.tpl.php).
Drupal 7 – Check if the current loading page is the node view page of a specific content type

Sometimes we may even want edit the template file(.tpl.php) for specific content such as a content type node view. In Omega theme, there are different regions and by default they will use the following template files.

<drupal>/sites/all/themes/omega/omega/templates

  • region--branding.tpl.php
  • region--content.tpl.php
  • region--menu.tpl.php
  • region--sidebar_first.tpl.php
  • region--sidebar_second.tpl.php
  • region.tpl.php

Continue reading Drupal 7 – Customize region template file for specific content type

Drupal 7 – Disable certain regions by conditions using Context and Delta

We have talked about how to disable certain regions using the Context module.
Drupal 7 – Disable certain regions by conditions using Context

But seems that it may not work for certain themes and regions. Luckily, there is another module called Delta which could be served as an alternative. Delta not only could disable the region but it could alter any theme settings for specific context condition. Let’s take a look now.
Continue reading Drupal 7 – Disable certain regions by conditions using Context and Delta

Drupal 7 – Disable certain regions by conditions using Context

Context could help you to manage the layout. In the past, i would use the Page manager of Chaos Tool Suite and Panels to control the layout but now i have completely move to the Context module. You can decide which regions should be hidden.

However, i found that it may not work for certain regions and so i raise it in the Context project page. I will keep my eyes on it.
Context – Disable regions
Continue reading Drupal 7 – Disable certain regions by conditions using Context

Drupal 7 – Styling checkbox and radio button in Webform

Yesterday we talked about styling the checkbox and radio button as suggested by Ryan Fait.
Styling checkbox and radio button with CSS and Javascript

Here is a simple solution for applying the checkbox and radio button in Drupal 7 webform.

1. Upload the radio.png, checkbox.png and select.png to your subtheme. (Omega subtheme is used in this example.)

checkbox
radio
select

 
Continue reading Drupal 7 – Styling checkbox and radio button in Webform

Drupal 7 – Add Javascript files on specific paths by template.php

In my previous post, Drupal 7 – Add Javascript files on specific paths by custom module, we try to add .js files for specific paths by creating a custom module. Actually we could implement the same feature by using the theme template.php. Here is an example.
Continue reading Drupal 7 – Add Javascript files on specific paths by template.php