Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've wondered why $node is not defined anymore in my theme's page.tpl.php.
The reason is a modified expression in phptemplate.engine, which now reads:
if ((arg(0) == 'node') && is_int(arg(1))) {
arg(1) may be the node number, but it is a string variable, and therefore this check is always false.
is_int should be replaced with the code given in the patch.
Comment | File | Size | Author |
---|---|---|---|
#1 | phptemplate-is_int.patch | 739 bytes | Robrecht Jacques |
phptemplate_node.patch | 720 bytes | wiz-1 | |
Comments
Comment #1
Robrecht Jacques CreditAttribution: Robrecht Jacques commentedRerolled the patch (and changed the coding: eg Drupal uses "&&", not "and"). I think wiz is correct: you should use "is_numeric" here, not "is_int".
Comment #2
Dave Cohen CreditAttribution: Dave Cohen commentedConsider: if (arg(1) && ctype_digit(arg(1)));
reportedly performs better than is_numeric(), and true only for integers.
Comment #3
Dries CreditAttribution: Dries commentedCommitted to HEAD.
Comment #4
(not verified) CreditAttribution: commentedComment #5
(not verified) CreditAttribution: commented