I'm using taxonomy for drupal 5 as found here: http://drupal.org/node/108972

Looking for a particular answer led me to Lowell's version of taxonomy_menu for use with pathauto: http://drupal.org/node/41450

Lowell's code is for drupal 4.7, and was never comitted to CVS. So I tried making a drupal 5 version. Time constraints meant this is as far as I got:

I took Lowells taxonomy_menu.module (http://drupal.org/node/41450#comment-169796) applied the "#21 patch" (http://drupal.org/node/108972#comment-184357).

patch got stuck on the first hunk. The rest were fine. I tested it, and it actually kind of works. menu table gets populated correctly, but on output, the <li>'s don't get nested -- even though the table has the correct pid. Any ideas?

I've zipped the folder including the .rej file and attached it.

Additionally it breaks DHTML menu.

CommentFileSizeAuthor
taxonomy_menu.zip__0.txt18.45 KBBevan

Comments

riemann’s picture

Hi bevan,

did you get Lowell's hack working in Drupal 5?

I played around with it, but I always end up with subcategories/subterms being placed all over the navigation-root-level of the menu instead of being hierarchically ordered. Also, many items show up twice or trice.
Otherwise, links, path etc. are correct.

Where do you think the problem is burried? In the menu.inc or in the taxonomoy_menu.module?

Regards, riemann

Bevan’s picture

Hi there,

No I ddin't get it working. And there doesn't seem to be a maintainer for this module either. :(

B/

manne35’s picture

Hello all ,
i also worked 4 days to bring it to run. But no change for me.
(Maybe also my english was a too big shit...smile...)
I will wait now.
If there will be a solution i want to change from a joomla installation to drupal, cause i think its the better system (... but without the navigation i prefere to wait ).
Thanks for all who work for drupal and bring it forward.
best regards
manne

Bevan’s picture

As a temporary solution, you can probably manually create the menus for your site. That's what joomla does by default. As far as I know joomla doesn't have this functionality in it's default distribution. Maybe in it's extensions...?

Bevan’s picture

I'm using this code in .htaccess to rewrite taxonomy_menu URLs as taxonomy/term/nn, which global-redirect then takes care of, by redirecting the user appropriately:

# Rewrite taxonomy menu urls. this would ideally be done in taxonomy menu module
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /taxonomy_menu/.*$
RewriteRule ^.*/(.*)$ /index.php?q=taxonomy/term/$1 [L]

Above

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

The taxonomy_menu/nn/n urls are still output to the source, but are always redirected once clicked on.

If you want the ideal solution, I suggest you have a go at peterx's solution here: http://drupal.org/node/41476#comment-181146 and here http://drupal.org/node/103539. Core menu is such that it is impossible for taxonomy to write menu tree-paths that are different to drupal paths using hook_menu. So peterx's solution is rather complicated and requires several core hacks.

manne35’s picture

Hello,
yes, theses threads i had also tested 3 days . Now it seems to work , only if i want to hide the
>taxonomy term< in the breadcrump i get the error
Fatal error: Call to undefined function: function_stripos() in /kunden/steinschmuck.de/webseiten/stneu/themes/garland/page.tpl.php on line 72

            $breadcrumb_parts = explode(' » ', $breadcrumb);
            if(stripos($breadcrumb_parts[1], 'taxonomy term'))
                {
                unset($breadcrumb_parts[1]);
                $breadcrumb = implode(' » ', $breadcrumb_parts);
                }
            print $breadcrumb;

maybe its because on the server is php5 installed..?
Thank you all for your environment such a intuitiv user-orientationed CMS.

best regards
manne

htxt’s picture

@bevan,

Can you clarify how you have global redirect setup?

I tried the .htaccess trick but I just get 404s for all the taxonomy_menu links.

Thanks :)

Bevan’s picture

Category: bug » task
Status: Active » Postponed

@graphicsplus

I installed Global Redirect (latest dev version, not official release), Pathauto 5.x-1.1, DHTML Menus 5.x-0.7, and Taxonomy Menu 5.x-1.x-dev. Show the taxonomy menu block in admin/build/blocks, then check that the menu items in that block link to taxonomy_menu/[tid]/[tid]/[tid]. Where [tid] is an integer that is the tid of the term, or one of it's ancestor terms. Make sure clear URLs are enabled and working.

Now look for this code at the bottom of .htaccess:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the prefix www. you
  # can use one of the following settings to force user to use only one option:
  #
  # If you want the site to be accessed WITH the www. only, adapt and
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
  # and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule .* http://example.com/ [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form &apos;node.php?id=x&apos;.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&amp;]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form &apos;module.php?mod=x&apos;.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&amp;]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form &apos;index.php?q=x&apos;.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

Replace it with this:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the prefix www. you
  # can use one of the following settings to force user to use only one option:
  #
  # If you want the site to be accessed WITH the www. only, adapt and
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
  # and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule .* http://example.com/ [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form &apos;node.php?id=x&apos;.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&amp;]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form &apos;module.php?mod=x&apos;.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&amp;]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite taxonomy menu urls.  this would ideally be done in taxonomy menu module
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} /taxonomy_menu/.*$
  RewriteRule ^.*/(.*)$ /index.php?q=taxonomy/term/$1 [L]

  # Rewrite current-style URLs of the form &apos;index.php?q=x&apos;.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

The bit that's different here is

  # Rewrite taxonomy menu urls.  this would ideally be done in taxonomy menu module
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} /taxonomy_menu/.*$
  RewriteRule ^.*/(.*)$ /index.php?q=taxonomy/term/$1 [L]

which is essentially the same as

  # Rewrite current-style URLs of the form &apos;index.php?q=x&apos;.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

just below it. Except that it has an extra condition, and it changes the path. I've commented it extensively below. These give a complex instruction to apache about how to handles an http request.

  RewriteCond %{REQUEST_FILENAME} !-f # If this path isn't a file on the filesystem (like files/images/photo.jpg),
  RewriteCond %{REQUEST_FILENAME} !-d # and this path isn't a directory on the filesystem (like files/images),
  RewriteCond %{REQUEST_URI} /taxonomy_menu/.*$ # and this path contains the string '/taxonomy_menu/' (including the slashes, e.g. '/taxonomy_menu/23/56/3') (should work okay without friendly urls if you remove the leading slash),
  RewriteRule ^.*/(.*)$ /index.php?q=taxonomy/term/$1 [L] # then don't look for a file that matches 'this/current/path/lastdir', instead look for /index.php?q=taxonomy/term/lastdir', and stop processing rules for this request ([L] for last).

This causes drupal (index.php) to look for a page or node that maps to drupal path 'taxonomy/term/[tid]', where [tid] is the part of the path after the last slash, or the tid of the current term. Global redirect intercepts this and redirects to the url_alias for taxonomy/term/[tid], which was probably set by pathauto when the term was created, or when pathauto mass generated url_aliases.

This method unfortunately means that taxonomy menu can no longer set the active term with <li class="active">. As menu.module can no longer see what path through the (taxonomy_menu) menu was taken to get to this menu item. To be able to do that, a change is being made to menu.module in drupal 6: http://drupal.org/node/103539. However I recently heard that hx is rewriting menu.module for d6. I'm not sure if/how this will affect peterx's patch.

For the above reason we've undone the hack described here in my client's site. You might find it useful for how the modules are configured though: http://www.bwmsnow.co.nz. We're using DHTML menu on the taxonomy menu, so defining the active menu item is necessary in the 'shop' taxonomy menu. For many other sites, especially if the taxonomy menu is working on a flat vocabulary, like the 'brand' taxonomy menu, this hack might still be useful though.

htxt’s picture

Great writeup, thanks for the info ;)

I could only get this to work by removing the [L] flag, so the code looks like:

	# Rewrite taxonomy menu urls.  this would ideally be done in taxonomy menu module  
	# If this path isn't a file on the filesystem (like files/images/photo.jpg),
  RewriteCond %{REQUEST_FILENAME} !-f 
	# and this path isn't a directory on the filesystem (like files/images),
  RewriteCond %{REQUEST_FILENAME} !-d 
	# and this path contains the string '/taxonomy_menu/' (including the slashes, e.g. '/taxonomy_menu/23/56/3') (should work okay without friendly urls if you remove the leading slash),
  RewriteCond %{REQUEST_URI} /taxonomy_menu/.*$ 
	# then don't look for a file that matches 'this/current/path/lastdir', instead look for /index.php?q=taxonomy/term/lastdir'.
  RewriteRule ^.*/(.*)$ /index.php?q=taxonomy/term/$1

But it works, which is what counts :)
I also cleared the url_alias table, reinstalled pathauto, and bulk-updated all the category paths, if anyone's having similar problems.

Bevan’s picture

Interesting. Not sure why it only worked without [L].

tille’s picture

Title: Lowell's pathauto hack for drupal 5 » desperation..

i was installing the taxonomy_menu.zip_.. as a replacement for taxonomy_menu.module .. - ..and now literally desperately trying to get this working - but i'm having these 'nice' problems:

• getting very nice url-aliasses after bulk url generation trough pathauto.. - ..hurray..:]
• but the menu kind of exploded - instead of heavin a hirachy in a seperate menu its all on 'top level' in the main navi-menu..
• getting negative id-numbers in the admin area
• cant modify nor delete nor do whatever to the dynamically created menu items

..does anyone have a 1-2-3-instruction on how to do this on drupal 5..?

..thank you very much, greetz, till..

tille’s picture

Title: desperation.. » Lowell's pathauto hack for drupal 5

..sorry - didnt want to change the title - so this post is now only for changing it back...

greetz, t..

Bevan’s picture

Please read my first post starting this thread -- actually the whole thread... I wouldn't try and run this on your site, it needs a lot of work, and there are better solutions coming from other peoople anyway...

summit’s picture

Hi,

I tried this .htaccess hack in Drupal 4.7...but it didn't work.
Should it normally also work for drupal 4.7?

Thanks in advance for your reply.
greetings,
Martijn

summit’s picture

Title: Lowell's pathauto hack for drupal 5 » .htaccess hack did work for drupal 4.7 also

Hi,

I made a mistake myself. I needed to make manually the vocabulary taxonomy_menu items, and than it worked.
Are there other issues with the .htaccess solution, than stated above?

greetings,
Martijn

summit’s picture

Title: .htaccess hack did work for drupal 4.7 also » Lowell's pathauto hack for drupal 5

oeps changed the title..sorry

Bevan’s picture

Hi, not that I know of, although we're not implementing this system, so I haven't tested it extensively

tille’s picture

hello everybody - once again..:]

I used 'category' in between.. but that brings sooo many little helpers (and problems) that I went back to taxonomy menu.. or lets say I'm trying to give it another try..:]

@ bevan. 'there are better solutions coming from other people anyway'. - ..what do you mean..? ..is there..?! the htaccess-'hack'..? ..wel - if thats the only way to do a clean taxonomy menu - I'll go for it.

whatever - kind of 'down' after installing and 'de-installing' various modules again - and again - and again.. cant really believe that theres no solution to this 'problem' of having a 'nice' menu AND 'nice' urls for the beloved taxonomy.....?!¿

well - greetingz, till..

greggles’s picture

Title: Lowell's pathauto hack for drupal 5 » Taxonomy_menu support for Token/Pathauto

This seems like a better title. If it does ever get implemented, note that the Pathauto API has changed since this was originally written...

arlinsandbulte’s picture

Status: Postponed » Closed (won't fix)

This is quite old and according to #19, probably does not even apply anymore anyway...
Marking as won't fix

johnv’s picture

Version: master » 5.x-1.x-dev

Reassigning, to not show anymore in 7.x issues.