Tag Archives: Drupal Development

Drupal 7 – Add Javascript files on specific paths by custom module

In the past, i always added js files on theme level. This is not a good approach because the aggregated theme js will be quite large and it is loaded on every pages even js code is not used.

So this time i try to add the js on specific path only when it is needed. This is done by creating a custom module. Let’s name the custom module eureka_js.

1. Inside the eureka_js module folder, we have the following files.

  • js/eureka.js
  • eureka_js.info
  • eureka_js.module

Continue reading Drupal 7 – Add Javascript files on specific paths by custom module

Working with menus in Drupal 7 @ 3

We have Special menu items module and Nice Menus which makes Drupal menu editing much more convenient.
Working with menus in Drupal 7 @ 1 – Special menu items module
Working with menus in Drupal 7 @ 2 – Nice Menus

But there is a bug when using both of them together. After you setup a Nice menu and you set the parent menu item path to <nolink>, the hyperlink is still there. Continue reading Working with menus in Drupal 7 @ 3

Drupal 7 – Get number of nodes of Taxonomy Term in Views

About 2 months ago i published a post on how to get the number of nodes of a specific taxonomy term by term ID.
Drupal – Get number of nodes of Taxonomy Term by Term ID

Unfortunately, the taxonomy_term_count_nodes() no longer works in Drupal 7 but you can get the count by Views in D7.
Continue reading Drupal 7 – Get number of nodes of Taxonomy Term in Views

Drupal – Show a node location with Google Map in Views

We could add location information to node using the Location module. If the GMap module is enabled, we could even show the location with Google Map in Views.
1. Download and enable the GMap module.
 

2. Edit the Locative information of any content type. Make sure the Coordinate Chooser is set to Allow. Continue reading Drupal – Show a node location with Google Map in Views

Drupal – Get CCK Allowed Value Label

We can create a CCK selection list or checkboxes field with a list of allowed values in key|value pair. normally when you retrieve a node content, what you get is only the key instead of the value.

Suppose we have a content type called Silly Question(silly_question) with a field called Option(field_option) which has the following allowed values. Continue reading Drupal – Get CCK Allowed Value Label