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
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>
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
l('<link text>', '<link path>', array('attributes' => array('class' => array('class-a', 'class-b'))));
Reference: Drupal API – l()
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.
Continue reading Drupal 7 – Customize region template file for specific content type
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
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
Yesterday we talked about styling the checkbox and radio button as suggested by Ryan Fait.
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.)
Continue reading Drupal 7 – Styling checkbox and radio button in Webform
Sometimes we may want to render a data without the theme page template. This is useful when we want to retrieve data through asynchronous call such as Ajax.
So let’s create a page content only .tpl.php in the theme folder called page-ajax.tpl.php. Continue reading Drupal – Render a page without page template for Ajax