Posted by 916Designs on March 27, 2009 at 11:23pm
Jump to:
| Project: | Taxonomy Redirect |
| Version: | 6.x-1.3 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hello, I'm trying to "Just make your PHP code return the desired path." but the redirect isn't happening. My code is properly displaying debugging, so php input is working.
<?php
if (arg(0) == 'taxonomy' && arg(1) == 'term' && ctype_digit(arg(2))) {
$term = taxonomy_get_term(arg(2));
$name = $term->name;
}
if ( $name == 'Hotels' ) {
drupal_set_message('redirected!<pre>'.print_r($term,TRUE).'</pre>','status',TRUE);
/*return 'taxonomy/term/!tid/hotelslist'; FAILS */
return 'taxonomy/term/' . $term->tid . '/hotelslist'; //Also FAILS
}
else {
drupal_set_message('redir fail','status',TRUE);
drupal_set_message('<pre>'.print_r($term,TRUE).'</pre>','status',TRUE);
return 'taxonomy/term/!tid';
}
?>The if statement is properly finding that I'm clicking on a "hotel" term, but the view that pops out is the standard taxonomy view. Am I returning the wrong data type?
Thank you!
Comments
#1
Update
The above php path setting works fine. Hook term path is returning the value I want.
However, somehow my redirect fails. Im trying to redirect to a view with a path of hotels/% and pass in the tid. The final path is set to hotels/123. Manually typing this url in works fine,
Help..
#2
I think this is the problem:
"This means the redirect only works for taxonomy links placed by the taxonomy module. It also means if you type the url in to your browser the redirect doesn't work."
I am creating these taxonomy links myself. They failed to redirect both with hardcoded taxonomy/term/123 and
l('whatever', taxonomy_term_path($term)). It also seems that breadcrumb links cannot be redirected.
How can I properly create links that this module will redirect???
#3
#4
What you are doing doesn't seem to make a lot of sense.
If you use the code
if (arg(0) == 'taxonomy' && arg(1) == 'term' && ctype_digit(arg(2))) {it is only going to ever work when you are already on the taxonomy/term/ view
Then doing
if ( $name == 'Hotels' ) {is only going to match if the term name is 'Hotels'. Are you trying to match the term 'Hotels' or any terms in the vocabulary 'Hotels'?
If i you are trying to redirect all terms in the vocabulary 'Hotels':
* Create a new redirect for the Hotels vocabulary and don't select any terms so it works on all terms of the vocab
* For the path, use plain text, not PHP, and enter: hotels/!tid
This will redirect taxonomy term links to hotels/% if % is the term id
And yes, this module does not create url aliases, it just rewrites the taxonomy term links that appear on nodes.
Let me know if this helps, otherwise if I have not correctly understood your requirements please state them more clearly.
#5
Marking the solution in #4 as fixed.
Please reopen this if hat is not the case.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.