Lets say I have a taxonomy called fruits. I have 3 links on my front page and the href-s are:

fruits/bananas fruits/oranges fruits/apples

I made a custom module to do this but I am not really sure what to do next...

function mymodyle_menu() {
    $items['fuits/%'] = array(
      'page callback' => 'mymodule_fruits',
      'access callback' => TRUE
    return $items;

  function mymodule_fruits() {
  //what to do?

I also have a template file for them. How to do this?

  • Do you just want to have a custom link for the taxonomy page or are you trying to accomplish something else? – Mohammed Shameem Jan 23 '13 at 9:38
  • I didn`t get your question well, but if you mean you want to display some information about the taxonomy that is just clicked, or print some related taxonomies you can use views contextual filter. – Reza Shadman Jan 23 '13 at 9:48

If you just want a custom pattern for the URL then you are better of with Pathauto module

Once you enable the module if you go to Admin -> URL Alias you will get a new TAB Pattern. In that you can define the pattern that you want to give to the taxonomy page. By default it would be [term:vocabulary]/[term:name]

So if your vocabulary name is fruits and your term name is apples then the url will automatically be turned into fruits/apples

After you enable the module you might have to do Bulk Update from URL aliases for the urls to take effect.

If the requirement is to add more information regarding the taxonomy terms or nodes with in the taxonomy term then you should use the views module

If you are simply trying to learn the how things work with in drupal then you should check the examples module it has got all sorts of modules to get you started with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy