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

Comments

adrian’s picture

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

Bèr Kessels’s picture

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

Ber

morbus iff’s picture

+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.

chx’s picture

StatusFileSize
new829 bytes

Morbus is right.

chx’s picture

StatusFileSize
new1.43 KB

Dries is also right that some code can be removed.

dries’s picture

Status: Needs review » Fixed

Committed to HEAD.

morbus iff’s picture

Status: Fixed » Active
StatusFileSize
new2.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.

morbus iff’s picture

Status: Active » Needs review
chx’s picture

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

morbus iff’s picture

StatusFileSize
new3.23 KB

Somehow, I forgot bluemarine.

dries’s picture

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.

drumm’s picture

Status: Needs review » Needs work

I agree one variable is better than two.

Jaza’s picture

Version: x.y.z » 4.7.x-dev
Status: Needs work » Closed (fixed)

This issue appears to be fixed by the existence of the 'toggle_node_user_picture' variable in PHPTemplate. Closing.