(-> Latest version)
When I enable "Hierarchy" within taxomomy (Hierarchy modul itself is installed) an empty menu shows up.

CommentFileSizeAuthor
#21 summit.zip1.25 KBindytechcook
#18 summit.zip1.15 KBindytechcook

Comments

indytechcook’s picture

I saw that yesterday and thought I had fixed it. I will make sure I committed the changes.

ksc’s picture

I just installed the version of 2nd of march (latest) - so my issue was from the dev-version before.
Now let me see what is happening....
(I allways uninstall the older version)

No menu shows up at all, when "Hierarchy" is selected.
I tried "Item for vocabulary" checked and unchecked.
I tested "normal" taxonomy and cck-made taxonomy.
Klaus

indytechcook’s picture

hmm... I'll test tonight.

I was going to make this version beta1 then start working on some the changes for the next release. version 3 maybe? #388486: Basic considerations for latest version

summit’s picture

Hi,

Same problem here. Only an empty menu item is added.
Subscribing.
Thanks for going into this!

Greetings, Martijn

indytechcook’s picture

OK. I wasn't able to reproduce this. I did have it happen to be yesterday before I made a change. I downloaded the latest DEV version dated March 1st and the code matched what I had locally. Just to be sure it's not some funky release issue. I have created a BETA1 release.

To fix this yesterday I used the reinstall module link on the devel block (http://drupal.org/project/devel) I thought this was the same as uninstalling then reinstalling but maybe not. Please give that function a try and let me know if it doesn't resolve the issue.

indytechcook’s picture

Status: Active » Fixed

After my wife gave me a hair cut, it enlighten my head. I realized why I am able to get the menu items to show up and you are not. The hierarchy path requires a custom call back (views or using hook_menu for custom code) If you do not have a valid callback then the menu items will not appear.

Create a view with the path 'category/%' then rebuild the tax menu and they will show up.

The hierarchy path was just for legacy support in custom modules. They visual effect of having the url be category/vocab/term/term... can be solved using pathauto setting the path to 'category/[vocab-raw]/[copath-raw]' This uses the menu call back of 'taxonomy/term/%tid' so you use either use the default taxonomy handling or a view with the path 'taxonomy/term/%'

summit’s picture

Hi,

Will test your proposal.
So first I need to build a view, not important what name? with path category/%
Then rebuild taxonomy_menu instead of de-install?
Than build through path settings: category/[vocab-raw]/[copath-raw] to keep the hierarchical settings which I use in my site.
Right?

Greetings,
Martijn

indytechcook’s picture

I mixed topic in my last post. Let me separate and try again.

The hierarchy path selection should only be used if you have a module that requires the arguments passed from the previous versions URL format.

If you have no code that relies on the url arguments and you want your URL to look like category/vocab/term/term.. then the recommendation is to set the path to 'default' in taxonomy menu and set the pathauto to category/[vocab-raw]/[copath-raw].

Martijn, do you have code that relies on the legacy URL?

For testing purposes, you can create a view with the path of 'category/%' and the menu items will show up.

summit’s picture

Hi,

Thanks for your quick update.
If have former taxonomy_menu working with category/vocab/term/term.. so I think I have to set the path to 'default' in taxonomy menu and set the pathauto to category/[vocab-raw]/[copath-raw] then.
And this means I have no legacy URL, I think...What is legacy URL please?

I will test this this evening!

greetings,
Martijn

indytechcook’s picture

Legacy URL refers to supported the previous. Just in case someone did some custom coding against the old URL structure, they can still upgrade to this version. I don' see it being used very often.

summit’s picture

Hi,
Thanks for the explanation. As I told you I would test this evening, so I have.

You can see this on: http://www.aanbiedingen-herfstvakantie.nl/
It works as you advocated. I used hierarchy setting, and builded a testview just to roll the hook I think? GREAT!

Now I can build hierarchical pages in D6 with taxonomy menu and other people can use taxonomy/term/[tid], right?

The only thing I do not get is the pathauto setting as you explained: [vocab-raw]/[copath-raw]
Is it so this setting can be used, AND the normal pathauto setting, so is copath-raw for both situations?
I ask this because almost all terms are pathauto-ed with the regular [catpath-raw] and I would very much to have this still.

Thanks a lot for all your effort until now!
Greetings,
Martijn

ksc’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta1

Martijn,
I´m following this thread.

Could you display content with Menu path=hierarchy using a view?
I looked at your site - but couldn´t see content under geografisch/nederlands.
I have the same problem.

see http://drupal.org/node/389756

Thanks Klaus

summit’s picture

Hi Klaus,

Thats my second task with this!
And Yes I think I can get it to display the content I want, but may be that is not sufficient for you. It is not the taxonomy/category content I want to display.

I will use the hierarchical posibilities of /VID/TID/TID to show different templates.
This week I will try to get this done, and than you can see what I am talking about.

I did this already with a D5 site: www.wintersport-accommodaties.nl
It uses a little peace of code in settings.php to do this, see thread: http://drupal.org/node/192493

Hopefully it works the same in D6. Keep you posted.

Greetings,
Martijn

indytechcook’s picture

Sorry for not responding to this yesterday. I had a cooking class and fell into a food comma.

The only thing I do not get is the pathauto setting as you explained: [vocab-raw]/[copath-raw]

It doesn't really matter what your autopath is set to . The only function path has is to change the display of the URL. Every argument sent to PHP (using the arg(x) command) is from the actual path and not the alias. I was only saying that you can have the URL display the way the previous version did by using the default path and autopath. It won't work for your situation though.

You may also look into using taxonomy_term_path with hook_term_path. This sets the term path to what every you want everywhere, not just taxonomy menu. If you do use this hook, I honor it in the default path. I didn't find this hook until this past weekend and have been thinking of removing hook_taxonomy_menu_path. The only reason I haven't is so you have somewhere to set the vocab item path. I just haven't updated the development documentation for my recommendation.

Here is the callback code for the default path selection. If you do something custom and will not be displaying a vocab level item, then I recommend you use the default path and hook_term_path to set the custom path.

If you use this method, then you can also use taxonomy setting in autopath correctly. Using this one hook could cut down on a ton of custom coding.

function taxonomy_menu_path_default($vid, $tid) {
  //if tid = 0 then we are creating the vocab menu item format will be taxonomy/term/$tid+$tid+$tid....
  if ($tid == 0) {
    //get all of the terms for the vocab
    $vtids = _taxonomy_menu_get_terms($vid);
    $end = implode(' ', $vtids);
    $path = "taxonomy/term/$end";
  }
  else {
    $path = taxonomy_term_path(taxonomy_get_term($tid));
  }

  return $path;
}

Sorry to bring this up now (better late then never) I just really didn't think about it before. I do thank you for your patience.

Neil

summit’s picture

Hi Neil,

I think the current working situation is sufficient for my situation.
I also think it is not the nicest way to have to build a testview with category/% to get things showing, so thats may be a point of attention still.

The custom code I will use in settings.php is something along the lines of http://drupal.org/node/192493#comment-633741 with custom_url_rewrite.
So I do not need pathauto support, because I will create the urls from the hierarchical level with custom_url_rewrite.
if top level TID then country panel
if nextlevel TID (TID/TID)) then province level
if nextnextlevel TID (TID/TID/TID) then city level
if nextnextnextlevel TID (TID/TID/TID/TID) then accommodation level.

I do not exactly understand how to use the function taxonomy_menu_path_default code. Will you bring that in on taxonomy_menu.dev?

greetings,
Martijn

summit’s picture

Hi Neil,

I have this code on a D5 site (without the <?php >?), but it is not working on D6.
D6 has now the function custom_url_rewrite_inbound(&$result, $path, $path_language) {
How can I alter this code, that it works on D6 please?

<?php
function custom_url_rewrite($type, $path, $original) {
# vocabulary = 5
 $vid = 5 ;
 $newpath = $path;
 $depth = 0;

 // This path was already aliased, skip rewriting it
 if ($path != $original) {
  return $path;
 }

// Rewrite to custom url:
  elseif ($type == 'alias') {
  if (substr($path, 0, strlen("taxonomy_menu/")) == "taxonomy_menu/") {
  $termid = substr($path, strlen("taxonomy_menu/"));
 
 
  $tids = explode("/", $path);
   if (is_numeric($tids[4])) {
     $term = taxonomy_get_term($tids[4]);
     $newpath = "city-info/". $term->name."/";
   }
   elseif (is_numeric($tids[3]))  {
     $term = taxonomy_get_term($tids[3]);
     $newpath = "region-info/". $term->name."/";
   }
   elseif (is_numeric($tids[2]))  {
     $term = taxonomy_get_term($tids[2]);
     $newpath = "country-info/". $term->name."/";
   }   
   
  }
 }
// Nothing to do:
 return $newpath;
}
?>

Thanks a lot in advance for your reply!
Greetings,
Martijn

summit’s picture

Hi Neil,

I have got something working.

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  global $user;
  $vid = 5 ;

  
    // Change all 'node' to 'article'.
    if (preg_match('|^taxonomy_menu(/.*)|', $path, $matches)) {
  
      $tids = explode("/", $path);
      
        if (is_numeric($tids[4])) {
          $term = taxonomy_get_term($tids[4]);
          $path = "city-info/". $term->name."/";
        }
        elseif (is_numeric($tids[3]))  {
          $term = taxonomy_get_term($tids[3]);
          $path = "region-info/". $term->name."/";
        }
        elseif (is_numeric($tids[2]))  {
          $term = taxonomy_get_term($tids[2]);
          $path = "country-info/". $term->name."/";
        }   
        elseif ($path <> '') {
            $path = 'geografisch'. $matches[1];
        }
         $options['base_url'] = 'http://www.aanbiedingen-herfstvakantie.nl';
         $options['absolute'] = true;
      }
    
}

See: www.aanbiedingen-herfstvakantie.nl
But I see also that other vocabularies also get the taxonomy_menu settings (and I build testview with taxonomy_menu/%).
I did not be able to check for the right vocabulary, which is 5. I go to bed now..too long programming evening..
Greetings,
Martijn

indytechcook’s picture

StatusFileSize
new1.15 KB

I see what you are trying to do now. Here is a way to do this without any custom code. I am working on a way to do this without having to manual change the menu.

Create 3 vocabularies:
City
Region
Country

indytechcook’s picture

Thinking about this overnight, the code I wrote might have an issues with $term->depth. I'm not sure the term object has the depth indicator in it.

summit’s picture

Hi Neil,

Great you are thinking with me to build this solution. With this taxonomy_menu can become the module to build hierarchical websites!

I tried something like underneath to get to the depth.., but it doesn;t work:

<?php

/**
 * Implementation of hook_term_path()
 */
function summit_term_path($term) {
  $terms = taxonomy_get_tree($term->vid);

  foreach ( $terms as $term ) {

   if ($term->depth = 0) {
     $base_path = 'country-info';
   }
   elseif ($term->depth = 1) {
     $base_path = 'region-info';
   }
   elseif ($term->depth = 2) {
     $base_path = 'city-info';
   }
  }
  return $base_path .'/'. $term->name .'/';
}?>

Please help me out with this, thanks!
Greetings,
Martijn

indytechcook’s picture

StatusFileSize
new1.25 KB

Here you go Martijn,

I test this one and it appears to work pretty well. Use a view with an argument of $tid.

I am able to use some of this code to implement new features but deeper so coding this for free wasn't a problem, but if you need more customization, please contact me via my contact form and we can make arrangements.

Thanks,
Neil

summit’s picture

Hi Neil,

I am not getting the depth to work. I changed the $depth country to 1, so the country Nederland (holland) gets country-info, but all terms underneath also get country-info, instead of region, city.

/**
 * Callback for taxonomy_menu_path
 */
function summit_path($vid, $tid) {
  $term_tree = taxonomy_get_tree($vid);
  
  foreach ($term_tree as $term) {
    if ($term->tid == $tid) {
      if ($term->depth = 1) {
        $base_path = 'country-info';
      }
      elseif ($term->depth = 2) {
        $base_path = 'region-info';
      }
      elseif ($term->depth = 3) {
        $base_path = 'city-info';
      }
      $term_name = $term->name;  
    }
  }
  $path = $base_path .'/'. $term_name;
  return $path;
}

The menu_items from the geographical vocabulary have all the path: "country-info",
See: www.aanbiedingen-herfstvakantie.nl, the top item 'Nederland' and underneath.

Thanks still for getting into this!
Greetings, Martijn

summit’s picture

HI Neil,
May be I do this wrong. Your remark was

Create 3 vocabularies:
City
Region
Country

But I need one vocabulary:

-Country
---Region
------City

Region is one term depth deeper.

May be I do this wrong..sorry than, I can't get the depth working, it is not showing the region and city custom urls: region-info, city-info.
EDIT: I updated back to your original summit.module, It only shows region-info on all depth levels...I just can't figure out how to change it..I am not a good enough programmer..sorry.

Thanks a lot for helping me. I really think that this can be an upgrade of taxonomy_menu to have hierarchical_templates support.
Greetings,
Martijn

indytechcook’s picture

I said use 3 vocabularies before I really knew what you were trying to accomplish. What you want is planed for the v3 version of taxonomy menu. klaus give me the idea to use taxonomy menu groups. It's though to explain but very flexible.

I'll try to take a look at this again.

summit’s picture

Thanks Neil, tried to figure out myself..but unsuccesfull. Looking forward to your solution!
greetings,
Martijn

summit’s picture

Hi Neil,

I can first try to work with my settings.php solution. I need to enhance it a little bit more to work only for the vocabulary I want. But I think I can handle this.
Than you can work on taxonomy menu groups solution to have the broather/structural solution.
Is this a good workplan?

Or do you think I can better wait a little bit to test your solution immidiately?
Greetings,
Martijn

indytechcook’s picture

Go ahead. I don't have an immediate fix with out debugging the code. Good Luck!

summit’s picture

Hi Neil,

Do you have a rough planning for the solution withing taxonomy_menu_group ?
I will investigate the settings.php solution.
Will this work (not behind pc with ftp etc..):

<?php
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
   //The vocabulary which needs url_rewrite with taxonomy_menu enabled
   $vid = 5;
     // Get ID's: [VID]/[TID]/[TID]etc.. out of taxonomy_menu and place them in $matches ARRAY
    if (preg_match('|^taxonomy_menu(/.*)|', $path, $matches)) {
 
      //If the $vid matches the [VID] within the taxonomy_menu ARRAY then url rewrite
       if ($matches[1] = $vid) {
           $ids = explode("/", $path);
     
           if (is_numeric($ids[4])) {
             $term = taxonomy_get_term($ids[4]);
             $path = "city-info/". $term->name."/";
           }
           elseif (is_numeric($ids[3]))  {
             $term = taxonomy_get_term($ids[3]);
             $path = "region-info/". $term->name."/";
           }
           elseif (is_numeric($ids[2]))  {
             $term = taxonomy_get_term($ids[2]);
             $path = "country-info/". $term->name."/";
           }   
           elseif ($path <> '') {
               $path = 'geografisch';
           }
            $options['base_url'] = 'http://www.aanbiedingen-herfstvakantie.nl';
            $options['absolute'] = true;
       }
    }   
}
?>

Greetings,
Martijn

indytechcook’s picture

Yes. See here: #388486: Basic considerations for latest version

I don't know much about 'custom_url_rewrite_outbound' but from looking at the api, make sure you change 'taxonomy_menu' to what every the base path is.

It looks like the function custom_url_rewrite_outbound is called when the url is being created so this is called when the menu item is being saved. Be sure you have 3 views with the path matching the beginning of your path variable. Otherwise the menu items will not have anything to route and and will not be created.

Also be sure to use the hierarchy path since it's the only path that truly send the URL in the format you need.

summit’s picture

Hi Neil,
Still on the road..
1) Do you mean change "taxonomy_menu to what I described: country-info, region-info, city-info. Is this good?
2) I will have 3 panels, not 3 views. The panels will have block-view-panes. Is panels also ok for routing?
3) Yes I will use hierarchy path.

Off course this is only customizing, very eager to test your module-based new version!

greetings,
Martijn

indytechcook’s picture

1. I'm talking about this line
if (preg_match('|^taxonomy_menu(/.*)|', $path, $matches)) {

The part in bold has to match what you have in the "base path for hierarchy menu"

Panels should work fine, as long as menu item has a preexisting menu router item.

summit’s picture

Status: Closed (fixed) » Fixed

Hi Neil,
Again thanks. Will tell you if I got things working on one site, but another site, it is somehow not working.
I filled a new bugreport because it is not completely relevant for this thread.
http://drupal.org/node/402888

EDIT: working now, was a view problem.

greetings,
Martijn

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.