Tag Archives: Drupal Theme

Drupal 7 – Apply different theme based on path

Recently i have created a mobile website using Drupal. I would like to use another theme instead of the mobile theme in certain pages such as the user login page. This can be done by the ThemeKey module.

1. Instead and enable ThemeKey.

2. Go to admin/config/user-interface/themekey.
Continue reading

About these ads

Drupal 7 – Create your own theme function on your custom block

More than a year ago, we have talked about some basic theming in Drupal 6.

 

In Drupal 7, there is some changes on the theming functions as well as the block hooks. So here is a slightly modified versions from the example of Drupal – Introduction to Drupal Theming @ 3. The logic behind is exactly the same.

ykyuen.info
Continue reading

Drupal 7 – Override the .tpl.php in Advacned Forum

Advanced Forum has some default themes which are located @ sites/all/modules/advanced_forum/styles/<theme>.

Naked/Naked Stacked themes could be used for customization. So copy the .tpl.php which you want to customize in the sites/all/modules/advanced_forum/styles/naked folder to your theme folder.

For example, i want to customize the advanced-forum.naked.author-pane.tpl.php.
Continue reading

Drupal 7 – Customized comment.tpl.php for specific content type

The comment.tpl.php is located @<drupal-root>/modules/comment/comment.tpl.php. If you want to customize it for different content type. Copy it to your theme folder and rename it to

  • comment–node-<content-type>.tpl.php

For example, the machine name of Article is article. So the file name should be comment–node-article.tpl.php.

Done =)

Reference:

Drupal 7 – Strengthen the core Forum module by Advanced Forum

I am now working a new website project which includes a forum. With the Forum module bundled in the Drupal core. It is easy to build a forum based Drupal site. In the coming days, i would like to share suggestions when working on forum site.

First of all, you could equip your Drupal website with the basic forum features by enabling the core Forum module. However, that may be not enough for meeting the client’s requirements or it is difficult to customize it. That’s why we need the Advanced Forum module.
Continue reading

Drupal 7 – Apply sticky footer in Omega theme

We can make the section-footer sticky in Omega theme by adding the following piece of code in <your-theme>-alpha-default.css.

/* sticky footer */
html, body {height: 100%; margin: 0;}
#page {display: table; width: 100%;}
html>/**/body #page {height: 100%;}
*:first-child+html #page {height: auto;}
.section {display: table-row;}
html>/**/body .section-content {height: 100%;}
*:first-child+html body .section-content {height: auto;}

 

Kudos to Karl Kasischke.

Done =)

Reference: Has anyone tried to get a sticky footer to work with Omega?

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 – 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: