[drupal-devel] [feature] Flat out $node in phptemplate_node vars

drumm drupal-devel at drupal.org
Wed Sep 7 23:45:11 UTC 2005


Issue status update for 
http://drupal.org/node/24862
Post a follow up: 
http://drupal.org/project/comments/add/24862

 Project:      Drupal
 Version:      cvs
 Component:    theme system
 Category:     feature requests
 Priority:     normal
 Assigned to:  chx
 Reported by:  chx
 Updated by:   drumm
-Status:       patch (code needs review)
+Status:       patch (code needs work)

I agree one variable is better than two.




drumm



Previous comments:
------------------------------------------------------------------------

Sun, 12 Jun 2005 18:16:20 +0000 : chx

Attachment: http://drupal.org/files/issues/nodevarsflat.patch (907 bytes)

I'd like to write $whatever in node.tpl.php instead of $node->whatever .
Hence the patch.




------------------------------------------------------------------------

Sun, 12 Jun 2005 18:23:16 +0000 : adrian

i am gonna +1 this, as it simplifies the available variables.




------------------------------------------------------------------------

Wed, 15 Jun 2005 15:17:51 +0000 : Bèr Kessels

I Add my +1 to the 'heap' too. But a slight additional feature:
Maybe we should then omit teh $node completely. It makes not much sense
IMO to use the overheard of parsing along a rather often-used, and big
varible, when its availabe in another form already
Maybe you should do some checking for already existing variables. One
nevver really knows w




------------------------------------------------------------------------

Thu, 16 Jun 2005 18:08:35 +0000 : Morbus Iff

+1 to the flat, -1 to removing $node. I use various functions within my
templates that require a $node object to be passed to them.




------------------------------------------------------------------------

Sun, 17 Jul 2005 09:30:52 +0000 : chx

Attachment: http://drupal.org/files/issues/nodevarsflat_0.patch (829 bytes)

Morbus is right.




------------------------------------------------------------------------

Sun, 17 Jul 2005 19:50:01 +0000 : chx

Attachment: http://drupal.org/files/issues/nodevarsflat_1.patch (1.43 KB)

Dries is also right that some code can be removed.




------------------------------------------------------------------------

Sun, 17 Jul 2005 19:59:26 +0000 : Dries

Committed to HEAD.




------------------------------------------------------------------------

Mon, 18 Jul 2005 20:56:28 +0000 : Morbus Iff

Attachment: http://drupal.org/files/issues/_p_24862_pictures.patch (2.61 KB)

This patch causes a small bug with $picture. There exists a
$node->picture (the relative URL to the submitter's picture) and a
variables['picture'] (whether or not to show avatars within a
template). chx kindly ensures that the $variables array always
overrides anything in $node with $variables =
array_merge(object2array($node), $variables);. But, this doesn't work
if the template avatars have been set to OFF/Disabled/NULL in the
template settings. Since it's set to off, the $node->picture gets
seeded and the templates, checking on the existence of $picture, now
spit out the relative URL to the picture. The attached patch turns
renames $variable['picture'] to $variable['show_picture'].


This /shoudn't/ be an issue with comment pictures, because $comment is
not flattened.




------------------------------------------------------------------------

Mon, 18 Jul 2005 20:58:22 +0000 : chx

thanks Morbus. I have not played with $comment 'cos you can't extend
comment like you can node.




------------------------------------------------------------------------

Tue, 19 Jul 2005 14:14:57 +0000 : Morbus Iff

Attachment: http://drupal.org/files/issues/_p_24862_pictures_0.patch (3.23 KB)

Somehow, I forgot bluemarine.




------------------------------------------------------------------------

Tue, 19 Jul 2005 18:27:41 +0000 : Dries

To me it makes more sense to merge $show_picture and $picture.  If we
have a picture to show, set $picture.  If we don't have a picture to
show, make sure $picture is NULL.  One variable is better than one, and
gets the job done IMO.







More information about the drupal-devel mailing list