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.
Change "from" to "for"
"Show a hidden or already printed element from later rendering." should read "Show a hidden or already printed element for later rendering."
Comment | File | Size | Author |
---|---|---|---|
#14 | 930000-14.patch | 2.74 KB | jhodgdon |
#7 | 930000-7.patch | 2.84 KB | jhodgdon |
#1 | 930000.patch | 751 bytes | bleen |
Comments
Comment #1
bleen CreditAttribution: bleen commentedComment #2
moshe weitzman CreditAttribution: moshe weitzman commenteder, what does 'for later rendering' do for us? i say remove it.
Comment #3
kanani CreditAttribution: kanani commentedWell it doesn't actually show the value, it just sets a print flag for when render is called. And if render has already been called once, that flag is ignored if you call render again, but that's a separate issue http://drupal.org/node/929802
Comment #4
jhodgdonHow about "mark a ... for later rendering"?
And as long as we're fixing this function doc, "which" should always have a comma before it:
* Alternatively, render($element) could be used which automatically shows the
* element while rendering it.
and is that part clear at all? What do these two functions actually do anyway???
Comment #5
kanani CreditAttribution: kanani commentedI don't think either of these functions actually work as intended. If you step through the code in debug, you can see the $element getting altered by the function, but once you call render, any subsequent adjustments to $element get ignored the next time you render($element).
See the bug report I filed in #3 above. Maybe i should file a separate documentation bug?
Comment #6
jhodgdonOK, now you have me totally confused... I think this is all one documentation issue though.
Regarding #5 "Once render is called, show() and hide() have no affect on any subsequent calls to render()."... is this potentially because you didn't go high enough up in the render tree? (e.g. you said to show something, but it was already hidden higher up)? I guess I'm not understanding what is working, what isn't, and what you think should happen...
Comment #7
jhodgdonI did some more testing on http://drupal.org/node/929802#comment-3604502 and figured out what was going on, I think. Basically, show/hide only work before the first call to render(), because drupal_render() sets a #printed flag and never looks below the top level after the first call.
This needs to be documented on show() and hide(). Also, the render() documentation is wrong...
Here's a patch, which I think clarifies what happens in these functions.
Comment #8
jhodgdonComment #9
bleen CreditAttribution: bleen commentedI think #7 is a tremendous improvement ... I still had to read it read it twice before I fully understood, but I dont have any suggestions on how to make it better. Any other thoughts
Comment #10
droplet CreditAttribution: droplet commentedprint render($content) first, then hide($content['comments']) = hide() has no effect
print hide($content['comments']) first, then print render($content), and then show($content['comments']) = show() has no effect
Is it ??
so when to use show() ??
print show() first if render element set to #printed flag = TRUE by default ?
my test, I have removed all codes in node.tpl.php and paste @jhodgdon codes.
(I don't know what is the default behavior, so commented what I saw)
"Remove the first print render($content) line to test that if you hide initially"
** D7-dev up to date
Comment #11
jhodgdondroplet: Please clarify - are you reviewing the patch in #7, and do you think it is correct/complete, or does it need work?
Comment #12
droplet CreditAttribution: droplet commented@jhodgdon,
Yes, reviewed the patch. I have read many time and don't really understand until testing examples code.
I'm not sure if I understand this 100% correctly, so draw a conclusion in my word above.
#7 is correct and complete if users understand what is elements/elements tree
"on an element low in the element tree"
=> xxx ..... lower in...xx
=>on an child element in the render element tree..
It's more clear to me.
** I'm not a native speaker
Comment #13
jhodgdonOK, that is good feedback, thank you! I think we should change high/low terminology in the patch to use more parent/child terminology, as I think that is more standard.
Comment #14
jhodgdonHere's a patch that hopefully changes the wording about show/hide to something that is clearer and only uses child/parent tree terminology.
Comment #15
bleen CreditAttribution: bleen commentedThis is much, much clearer. RTBC++ for me, but lets give it one more set of eyes...
Comment #16
droplet CreditAttribution: droplet commentedComment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.