Hi,
Trying to get taxonomy_menu giving the right menu trail.
1) I have a correct taxonomy_menu working, using views:category and hierarchical menu path.
2) It is expanding correctly usnig normal taxonomy/term url-paths
3) I change the /VID/TID/TID/TID to nice hierarchical url's using the following snipper in settings.php
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
//The vocabulary which needs url_rewrite with taxonomy_menu enabled
$vid = 4;
// Get ID's: [VID]/[TID]/[TID]etc.. out of taxonomy_menu and place them in $matches ARRAY
if (preg_match('|^category(/.*)|', $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_land = taxonomy_get_term($ids[2]);
$term_regio = taxonomy_get_term($ids[3]);
$term_plaats = taxonomy_get_term($ids[4]);
$path = "regio/".$term_land->name."/".$term_regio->name."/".$term_plaats->name;
}
elseif (is_numeric($ids[3])) {
$term_land = taxonomy_get_term($ids[2]);
$term_regio = taxonomy_get_term($ids[3]);
$path = "regio/".$term_land->name."/".$term_regio->name;
}
elseif (is_numeric($ids[2])) {
$term_land = taxonomy_get_term($ids[2]);
$path = "land/". $term_land->name;
}
elseif ($path <> '') {
$path = 'node';
}
$options['base_url'] = 'http://www.top-vakantie-aanbiedingen.nl';
$options['absolute'] = true;
}
}
}
The only problem is that it is not expanding correct to the right term-level. I have the levels:
--country
----region
---------city
When the active menu-item is a country term, it is not expanding the underneath terms. And when the active term is on region or city level, the menu is not expanding at all.
To be honest, it is expanding nothing..
See for example the bottom menu on the right sidebar of http://www.campings-europa.com
I hope this module can help to get my taxonomy_menu expanding correct!
Thanks a lot for your support in advance.
greetings,
Martijn
Comments
Comment #1
Summit CreditAttribution: Summit commentedI forgot that in dutch country means "land". The top-url's of the taxonomy_menu are:
Sorry for that. Hopefully you guys can help me!
greetings, Martijn
Comment #2
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedDid you also implemented custom_url_rewrite_inbound(...) ?
Comment #3
Summit CreditAttribution: Summit commentedHi Dmitriy, No I didn't implement custom_url_rewrite inbound(..), should I, how should the code then look like?
Thanks for your quick reply!
greetings, Martijn
Comment #4
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedAccording to API examples:
http://api.drupal.org/api/function/custom_url_rewrite_outbound/6
http://api.drupal.org/api/function/custom_url_rewrite_inbound/6
function custom_url_rewrite inbound(..) should restore path to its original state, like it was before processing by custom_url_rewrite_outbound(..). I didn't even know about these functions before, so I can't say exactly how it should work.
Also, take a look at long standing bug about menu expanding. You can use patch or just apply my recommendation for this bug by hands to test it.
edit: Sorry, of course You already know about this bug.
Comment #5
Summit CreditAttribution: Summit commentedHi Dmitriy,
1) First, I off course want to change the urls VID/TID/TID to hierarchical levels:
S0 I think using the inbound, will change it back or something right?
2) I tried your patch
But it didn't change anything. Applied the patch to http://www.campings-europa.com (it is installed in the codebase right now...
Thanks for helping me further in advance.
greetings,
Martijn
Comment #6
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedPlease, try to implement custom_url_rewrite_inbound function, so system gets original urls.
Also, please, try both inbound function and patch together. Patch is necessary because your view's path has less parts than actual urls. You've probably set view's path to something like "category/%/%", but with url "category/1/2/3" it will not work without patch.
Comment #7
Summit CreditAttribution: Summit commentedHi,
I found this example:
But will the url itself not show /[VID]/[TID]/[TID] if I rewrite them back to the original /VID/TID/TID what taxonomy_menu hierarchical url's are.
The point is that I want per depth, which is build up bij amount of /TID/TID/TID's in the url a different rewritten url, like /TID = country, /TID/TID = region and /TID/TID/TID = city.
greetings,
Martijn
Comment #8
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedAs I understand, these two functions are used together to get nice readable visible url without broken handling of this url. System gets normal url and handle it right, users have their readable url. These functions are similar to path aliases and should be used together.
Comment #9
Summit CreditAttribution: Summit commentedSo you are saying that I need to build the url's back to their normal /VID/TID etc..form with custom_url_rewrite_inbound? But isn;t the url itself not shown than again as /VID/TID instead of land/[term_name]?
Comment #10
Dmitriy.trt CreditAttribution: Dmitriy.trt commentedPlease, read documentation to these functions carefully. Problem is not in Taxonomy Menu Trails. If implementing correct functions with patched core will not help, feel free to reopen this issue.
Comment #11
Summit CreditAttribution: Summit commentedOk will do. Thanks for your input! Greetings, Martijn