Posted by mariuss on March 14, 2009 at 9:01am
| Project: | Taxonomy Redirect |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Please document that you can use $tid and $tname in your PHP expression.
I finally saw them mentioned on the project's home page, but they are not mentioned on the README.txt or in the "Enter path" field description (and that's probably the best place to mention them).
Comments
#1
I have added it to the enter path description and the readme. I also made a couple of other updates to the readme as it was a little out of date.
These changes should be in the dev version sometime today and in the next release.
#2
Automatically closed -- issue fixed for 2 weeks with no activity.
#3
$tid seems to have no value for me?!
#4
I'm using the latest dev release, and $tid is coming up blank every time.
#5
#6
Just to clarify what I'm seeing:
We're using taxonomy redirect to change a path from taxonomy/term/[TID] via a custom module of our own that handles some rewriting of URLs and paths. I've ruled out our module, which works correctly if I hardwire a tid in the php editor in the taxonomy redirect admin page. That is, if I pass our function a valid tid such as "497" it works perfectly. If I pass it the variable $tid, it comes up blank. So in tracing this back, I located what I think is the code in the module, at line 506:
<?php$text .= '$tid = ' . $term->tid . '; ';
?>
I changed that to:
<?php$text .= '$tid = 497; ';
?>
...and it had no effect. The value of $term->tid is not empty, though. sending that out to watchdog from within taxonomy_redirect.module shows that line 506 has the correct value for $term->tid, it's just not getting picked up by the $tid in our PHP.
In the PHP evaluation textarea, here's our code:
<?phpwatchdog("TID", $tid);
$stuff = array('what' => 'resort', 'type' => 'term', 'id' => $tid, 'path' => TRUE);
return cd_misc_generate_link( $stuff );
?>
cd_misc_generate_link() is a function that creates a link or a path. the watchdog call returns nothing. Again, this works perfectly if we hardwire a $stuff[id] value, but not if we use $tid, so the problem is somewhere in the taxonomy redirect module. I've tried following the code, but i'm not familiar enough with the PHP filter to know exactly what's going on.
#7
Ok, figured this out. The problem seems to be that at line 515, the wrong string is being passed to check_markup():
<?php$path = trim(_taxonomy_redirect_exec_filter($redirect->path, $redirect->filter));
?>
should be:
<?php$path = trim(_taxonomy_redirect_exec_filter($text, $redirect->filter));
?>
Patch attached, rolled against the latest dev build.
--- taxonomy_redirect.module Wed Sep 16 17:50:19 2009
+++ taxonomy_redirect2.module Wed Sep 16 17:55:24 2009
@@ -512,7 +512,7 @@ function taxonomy_redirect_term_path($te
$text = $redirect->path;
}
- $path = trim(_taxonomy_redirect_exec_filter($redirect->path, $redirect->filter));
+ $path = trim(_taxonomy_redirect_exec_filter($text, $redirect->filter));
$separator = $redirect->separator_replace;
$remove_text = $redirect->remove_text;
$path_case = $redirect->path_case;
#8
Marked #606864: give the PHP code variables as a duplicate of this issue
#9
Committed fix in #7.
Thanks for the patch friolator.
#10
cool!
#11
Automatically closed -- issue fixed for 2 weeks with no activity.
#12
Any chance of resolved, tested bug fixes like this being migrated into the stable/recommended release? A year on and this is still broken in the (2008) 6.1.3 stable release.