views:

63

answers:

1

I found this code to work on my Drupal site. It outputs the taxonomy terms in a comma separated list. It successfully builds my taxonomy list to look like this:

Business, Entertainment, Leisure

While that's great, its using the same names to link itself in the url and so I get this:

www.yourdomain.com/category/Business

How can I make only the term name in the url lowercase to get it like this?

www.yourdomain.com/category/business

I believe I have to use this: string strtolower ( string $str ) but I'm not very php savvy. So where do I start?

    function phptemplate_preprocess_node(&$vars) {

      // Taxonomy hook to show comma separated terms
      if (module_exists('taxonomy')) {
        $term_links = array();
        foreach ($vars['node']->taxonomy as $term) {
          $term_links[] = l($term->name, 'category/' . $term->name,
            array(
              'attributes' => array(
                'title' => $term->description
            )));
        }
        $vars['node_terms'] = implode(', ', $term_links);
      }

}

Thanks for any help!

+3  A: 

You're on the right track with the strtolower() function, just apply it like so:

$term_links[] = l($term->name, 'category/' . strtolower($term->name),
jnpcl
Thank you!! Works perfectly.
Chris