* a quasi-fix/suggestion, whatever... *

Quick ugly hack for taxonomy_menu module users utilising the site_map module (Cross-posted) with bonus hack included!

Problem:

Category (or term) (hereinafter known as category) links generated by taxonomy_menu are not converted to their rightful clean-url (with pathauto) equivalents, resulting in duplicate paths...

EXAMPLE:
Wrong
Your site map spits-out URL's ending: -0 (/index.htm-0, for instance).
This is the duplicate URL and is a definite no-no... particularly in sitemaps which search engines are fond of.

Correct
/index.htm

Ideally (I believe), this is a taxonomy_menu issue but I needed a very quick-fix and site_map was the easiest victim to perform it in.

BONUS HACK!
That's right code-bloat-haters: If you hate those massive link-titles that're bulking-up your HTML mark-up - ya know, the link-titles taken from your category descriptions - then you'll find a FREE bonus secret hack included called HACK 1 (An easter egg, if you will).

That's right, FREE! (Even if you use this code at 3am in the morning!)

Dead easy - Simply follow the instructions below (No downloads or email addresses needed!):

site_map.module
(Starting at around line: 401 find the following chunk of code)

// Display the $term.
    $output .= '<li>';
    $term->count = taxonomy_term_count_nodes($term->tid);
    if ($term->count) {
      $output .= l($term->name, "taxonomy/term/$term->tid/$cat_depth", array('title' => $term->description));
    }
    else {
       $output .= check_plain($term->name);
    }

Replace the above with...

    // Display the $term.
    $output .= '<li>';
    $term->count = taxonomy_term_count_nodes($term->tid);
    if ($term->count) {
		
/* #####  HACK 1: Change loooong link-title's (as defined in your category/term description) to...  ##### */
/* ... the category/term name instead (Reduce page bloat) */
     $output .= l($term->name, "taxonomy/term/$term->tid", array('title' => $term->name));
/* END hack */

/* THE TAXONOMY_MENU HACK: Substitute index.htm-0 for index.htm ##### */
/* This kills duplicate paths in the form: index.htm-0 (generated because of taxonomy_menu module) 
from being used as links - Dupe paths = evil to users and search engines */
/*Very ugly hack but should serve as a quick-fix for taxonomy_menu users */
 $output = preg_replace('!index.htm-0!i', 'index.htm', $output);
 /* End hack */
    }
  else {
       $output .= check_plain($term->name);
    }

Note: Disregard HACK 1 if you're happy with the link-title length (mouse-over the generated links and judge length from the title's pop-up (oo-err!) description - If more than one line in length, highly recommend you leave it in-place to reduce code-bloat and remain true to the correct semantic use of link-title's)

ADDED:
I see there is a new release dated 13/11/06 (which buoys my spirits) - The above probably still applies but I've not (as yet) installed that release so just don't know.

Taxonomy-menu has probably been the single most important solution to my most annoying Drupal ills - I sincerely hope someone will bring it forward (and beyond) as I believe it's the nearest viable solution to Drupal's gaping (lack-of) support for hierarchical site-generation.

Thanks to the originator of this module and TIA to the next/current maintainer.

Comments

TheWhippinpost’s picture

Checked against the latest release (13/11/06) and it turns out I'd already applied the changes as a patch anyway so yeah... it should work with this release.

TheWhippinpost’s picture

Update Tax_Menu Category Aliases First (Pathauto)

I needed this fix again for the same dupe path issue caused by Tax_Menu, but for another part of my site.

Anyway, it occured to me that during this latest addition, I noticed that if I update path aliases through Pathauto, it will first update the categories pertaining to Drupal's taxonomy module, then the category paths for Tax_Menu.

This means that our Tax_Menu path aliases, end up with the dreaded "-0" appended to our aliased URL, rather than the other way around.

So, I had to reverse this by making sure Pathauto first updated the Tax_Menu categories first (So it has first stab at generating the correct path, without the appended "-0")

Do this, then - if needed - update the normal category aliases (So they get the "-0" appended instead).

TIP: Only update for the particular content-type you are targetting. IE...ensure the default path placeholder is empty.

brmassa’s picture

Status: Needs work » Closed (fixed)