Suppose we have a content type called Silly Question. We can theme the node template by adding the node-silly_question.tpl.php in the theme folder. But if we are working on a module, we should ask Drupal to read the .tpl.php in our module folder first because we shouldn’t ask the module user to copy the .tpl.php from our module folder to their theme folder.
Continue reading Drupal – Theme node template by module
Tag Archives: Drupal Theme
Drupal – Introduction to Drupal Theming @ 3
Update @ 20130303: For Drupal 7, please refer to the following post.
Drupal 7 – Create your own theme function on your custom block
Previous related articles
Drupal – Introduction to Drupal Theming @ 1
Drupal – Introduction to Drupal Theming @ 2
So we could now use a .tpl.php for our customized content. The last thing i would like to mention is about the preprocess function.
Suppose i want to load a node content on the .tpl.php, we can either include the node as an arguments when calling the theme function like. Continue reading Drupal – Introduction to Drupal Theming @ 3
Drupal – Introduction to Drupal Theming @ 2
Yesterday we have talked about the simplest way to theme Drupal content
Drupal – Introduction to Drupal Theming @ 1
But this is not a very good approach because printing inline HTML/PHP inside the theme function is not a good programming practice. This time, i want to create a .tpl.php for the block so we could separate the backend and frontend coding.
Create the following module. Continue reading Drupal – Introduction to Drupal Theming @ 2
Drupal – Introduction to Drupal Theming @ 1
The following module is an example which shows you the simplest way of Drupal themeing.
ykyuen.info Continue reading Drupal – Introduction to Drupal Theming @ 1
Drupal – Add Image to Apache Solr Search Result
Apache Solr is a very good web search engine and it works very well with Drupal. This post shows you how to customize the default pure text search result template by adding node image to each result record.
First, we need to load the corresponding node for each search result. This can be done in the <theme>_preprocess_search_result(&$variables) function. Add it to the template.php. Continue reading Drupal – Add Image to Apache Solr Search Result
Drupal – Add Alt Text to Site Logo
The theme in the following example is Fusion Starter. Open the page.tpl.php in the theme folder and search for the word logo. Continue reading Drupal – Add Alt Text to Site Logo
Drupal – Add Delete Link in Edit Comment Form
When you are editing a comment in Drupal, there is not delete option in the form. Continue reading Drupal – Add Delete Link in Edit Comment Form
Drupal – Add Previous and Next Links for Node Navigation
When you are viewing a node, it would be nice to have the previous and next navigation buttons so that you can browse other nodes of the same content type more easily. This is exactly the recent task i need to complete. Luckily i found a very good post showing how to add the navigation buttons in just 2 steps.
1. Add the following function in your theme template.php Continue reading Drupal – Add Previous and Next Links for Node Navigation
Drupal – Theme the Exposed Filter Form in Views
In Drupal Views, we can theme the output HTML by applying different .tpl.php in the Views admin UI. But there is not an option for theming an exposed filter. Actually, we can do it in the same way. Continue reading Drupal – Theme the Exposed Filter Form in Views
Drupal – Add page.tpl.php for different Content Type
In Drupal, we can determine the template files of the page which is going to be rendered. Add the following code in your template.php.
...
function <theme>_preprocess_page(&$vars) {
// Drupal 7
print_r($vars['theme_hook_suggestions']); exit();
// Drupal 6
print_r($vars['template_files']); exit();
}
...
Continue reading Drupal – Add page.tpl.php for different Content Type