Taxonomy -> Views redirection
Categories
Component ID
1332606
Component name
Taxonomy -> Views redirection
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Very simple module to convert taxonomy/term/xx to yyyyy/xx based on terms' vocabulary.
It is ok to use "taxonomy override view" (taxonomy/term/%) but when you have more content types and different
vocabularies it is not easily possible to use views "taxonomy override view". With this little tweak I can have one single view for
each vocabulary (which is enough for me so far)
function taxonomyviews_redirect_url_inbound_alter(&$path, $original_path, $path_language) {
global $user;
global $_GET;
// settings array
// [vocabulary_name] => [url]/%
$rewrites = array(
'firmy' => 'katalog-firem',
);
// taxonomy/term/237 = $path
// o-meste/firmy = $original_path (alias)
// only for taxonomy/term/xx pages
if (preg_match('@^taxonomy/term/([0-9]+)@', $path, $matches) ) {
$term = taxonomy_term_load($matches[1]);
foreach($rewrites as $vocname => $newurl) {
if ($term->vocabulary_machine_name == $vocname) {
//preserver arguments
preg_match('@^taxonomy/term(/.*)@', $path, $matches);
//perform url change
$path = 'katalog-firem'. $matches[1];
}
}
}
}
