Drupal theming

User login

Drupal 7: Addressfield - Change the order of the inner fields

A request that often comes up is to change the order of the Addressfield fields.
In this example, we are creating a custom module in order to position the Country field at the bottom.
It is a very simple function, and the other elements can be positioned in a similar fashion.

Drupal: Accordions in custom module - How to

If you'd like some fancy accordion on your module's output, here is a short recipe:

1.Download jquery_update.
Make sure that your jquery version is minimum 1.3.+ after the installation. This is required for the jquery_ui 1.7.x in step 2. An easy way to check the jquery version is to visit the drupal status report page under /admin/reports/status

2. Download jquery_ui.
Install it according to the instructions in the documentation.

Custom submitted by in tpl files

Here is a line of code to override Drupal's submitted by elements in node.tpl.php file.

<span class="submitted">

Show taxonomy terms Grouped By Taxonomy Parent

Lately I was assigned with the task to display all terms assigned to a node, grouped by their parent. To better explain this, let's say for example that we have the Vocabulary 1 assigned to Content Type A, with the following terms:
Parent 1
-- term 1
-- term 2
-- term 3
Parent 2
-- term 4
-- term 5
Parent 3
-- term 6
-- term 7
Nodes from Content Type 1 have various terms assigned. For example, node/143 has the following terms assigned: term 2, term 4, and terms 6 & 7.

Drupal: Run simple JS Scripts on a specific node

Let's say that you have a simple input form, on a specific node in your drupal site and you just want to reset it, using a button. There are a few ways you could go about it, but this one is probably the simplest one.
  1. Initialize global variable $base_url to gain access to functions base_path() and path_to_theme(), so that you can generate the script's path dynamically.

Drupal time ago function in template.php

Would you like to make time appear as an interval like "4 days 3 hours ago"? Possibly you have worked with such formatters (drupal time ago) in views and date fields, but what about editing a node.tpl.php for example? Or programmaticaly include the last login time of a node's author, as time ago, in a block?

It comes in handy when there is a reusable function to format our time statements as drupal time ago - and php in general. So here comes a little function to be included in the template.php file. You can easily use it in your themes to display a timestamp as "Time ago".

Internet explorer CSS errors?

We were working on a zen subtheme for a website when we came accross a very strange issue. Internet explorer would not render the CSS files properly. It would pick some css files, but more or less the page was scrambled. Strange issue indeed, as other browsers would display the content just fine.

After some experimentation, we realised that this is happening for both drupal 5 and 6, for internet explorer 6 and 7. Tried to disable some modules, and played around with the zen configuration, all in vain...

Subscribe to Drupal theming