Won't display when using PHP code
silurius - February 29, 2008 - 18:05
| Project: | Custom filter |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I created a filter under Drupal 5.7 and could use a little feedback.
Name: Revision Notation
Description: Prints "Last revised on" notation.
Pattern: /\[revision\]/i
Replacement text: <div align="right" class="caption"><?php print t('Last Revision: ') . format_date($node->changed, 'custom', "F jS, Y"); ?></div>
PHP checkbox: checked
When I preview a node with it, the viewport is entirely blank. Do I need to format my PHP differently?

#1
Forgot to mention, this same code works fine when added to node.tpl.php.
I've used it in both Filtered HTML and PHP code input formats with the same result. My Filtered HTML filter ranking is:
URL fiter - 0HTML flter - 1
Linebreak converter - 2
Hide email addresses - 3 (SpamSpan module)
Headngs to Anchors - 4 (table of contents module)
Table of Contents - 5 (table of contents module)
Term and Year - 6 (note: this is another custom filter)
Tablemanager fiter - 7 (tablemanager module)
Revision Notation - 8
(similar to PHP code filter ranking)
I moved this filter up to -1 and this did not seem to affect anything.
#2
The replacement text should be:
return'<div align="right" class="caption">'
. t('Last Revision: ') . format_date($node->changed, 'custom', "F jS, Y")
.'</div>';
The format of replacement text you provide is a feature that I plan to implement but still have no time to work in that.
Hope it helps.
Patches are welcome :)
#3
Success, sort of. I'm sure it isn't the fault of the module, but it appears that when code like this is used in this way, the date and time is: "December 31st, 1969" (beginning of Unix epoch?). When the code I posted above is used in node.tpl.php instead, it actually grabs the date the node is saved, so I think it's just a difference in how the the query is being executed. What does MySQL see in this case? Let me know if you need me to create a new issue for this one.
#4
I've tried the replacement rule and the date shown is January 1st, 1970. I've checked
$GLOBALS, seems that during filter process$nodehadn't been loaded yet. But when the code used in node.tpl.php,$nodehad been loaded, so it worked.Now I'm trying using node_load hook.
Ok, I think I need you to create a new issue.
Thanks.
#5
Ok, I've created a new issue. Feel free to close this one.
#6
#7
Automatically closed -- issue fixed for 2 weeks with no activity.