How to create nodes with hierarchical terms from excel

The purpose of this cookbook is to show how to create node from a excel documents via csv files.
The example we use is a list of stores with name, adress and three column to convert to terms a state,capital ubication and a kind of store column.

Create migrate module

First thing we are going to do is make a tipically module named migratestores.

Feed Import Taxonomy Terms

Feed Import is a module that allows you to import content into entities from various file types (like XML, HTML, CSV).
In this page we will find how to import taxonomy terms.

Display parent taxonomy term

Whether to assign only the lowest level taxonomy term to a page, or also assign the parent terms so that they display, is a frequent issue. This snippet allows you to display a parent term of a term already assigned to your entity. Note that this is not actually a term reference, so doing this will not allow you to list this page using the taxonomy system.

But if your term reference field is called myterm (field_myterm), you can use this to display a parent term. This assumes that there is just one parent term.

To make content taxonomy term sortable

To make a Content Taxonomy term sortable In a view display


  • Add a relationship in View page with group 'Taxonomy: Related terms '.
  • Then select the relationship and give the label and also the taxonomy term that should be sortable.
  • Then create a field by selecting taxonomy:term
  • Select relationship previously created , then give the label and save
  • This will create duplication to avoid this keep distinct field in Basic Settings as 'YES'.

About taxonomies

Taxonomy is the practice of classifying things. In Drupal, the Taxonomy module allows you to classify your website content, and it can be an important part of your information architecture.

Planning taxonomies

The first step in establishing a taxonomy is creating a new vocabulary. Next you provide the terms that fall within that vocabulary. The arrangement can be "flat," as in a tagging system, or hierarchical, with parents and children.

Here's how you might create a taxonomy for a site arranged by musical genre:

Vocabulary = Music
Term = Classical
Sub-term = Concertos
Sub-term = Sonatas
Sub-term = Symphonies
Term = Jazz
Sub-term = Swing
Sub-term = Fusion

Sometimes you will want to create a "controlled vocabulary," where content authors can assign terms that have been predetermined. If so, you will need to add those terms to your vocabulary in advance.

An alternative model for organizing information is the use of "tags." User-defined tags can be added to Drupal content on the fly. In Drupal 7, a ready-to-use "Tags" vocabulary is included by default, so users can immediately begin adding tags to their content.

Adding next & previous links for node types within taxonomy terms (e.g. Image Galleries)

A better way to do this using Custom Pagers module is detailed in the Image module documentation:


The following adds a custom next_prev function to your theme template.php file that allows you to insert NEXT | PREVIOUS type links in your layout.tpl.php files. Where layout might be node.tpl.php, node-image.tpl.php etc.

In the illustrative example snippet below, a simple NEXT | PREVIOUS link is inserted into a custom node-image.tpl.php file linking to the next and previous image within that gallery (taxonomy term).

step 1 of 2

Add the custom next_prev function to your template.php file.

  1. In a text editor like notepad.exe or equivalent, create/edit a template.php file and paste the following snippet
  2. Save your new/edited template.php file and upload it to your active theme folder

function next_prev for Drupal 5

function next_prev($current_nid, $type, $button_type, $label, $class) {
$tid = db_result(db_query(db_rewrite_sql("SELECT tid FROM {term_node} WHERE nid = $current_nid;")));
if (empty($tid)){ //validate that the image 'does' have a tid
return '';

switch ($button_type) {
case 'next':
$sort= 'ASC';
$case = '> ';

Subscribe with RSS Subscribe to RSS - taxonomy term