template_preprocessor_node() does $variables['page'] = (bool)menu_get_object();
That's not specific enough, it doesn't test "are we on *this node's* page"?
Forbids embedding nodes within nodes - see #658150-3: Nodereference D7 port.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 658314-node_is_page_2.patch | 4.63 KB | bleen |
| #27 | 658314-node_is_page.patch | 4.63 KB | bleen |
| #25 | 658314-node_is_page.patch | 4.72 KB | bleen |
| #24 | 658314-node_is_page.patch | 4.72 KB | bleen |
| #21 | 658314-node_is_page.patch | 4.76 KB | bleen |
Comments
Comment #1
dawehnerHere is a first patch, i think this still needs a test.
Comment #2
yched commentedThanks for being so quick !
This should do the trick, although I'm not sure why we need a strict comparison instead of a regular ==.
Not sure of the best way to test this either. Building a test module that uses page_alters to append a given node into the page of another node ?
Comment #3
dawehnerI tested it with eval php in a node body, but i'm sure your way is better :)
I used === because 1. its faster, 2. drupal should return the same database always, but i don't have a special reason why i chosed this.
Comment #4
moshe weitzman commentedI think we need this check in a couple module places. Lets put this check in own function like node_is_detail_page() or somesuch. Perhaps you can find similar cases by grep for menu_get_object().
Comment #5
dawehnerHere is new version, which fixes on every(i hope) place.
Comment #6
dries commentedPatch looks good to me, but it would be nice to have yched confirm that it would enable progress in #658150-3: Nodereference D7 port.
Comment #7
moshe weitzman commentedI think this would be a bit clearer in node_is_detail_page():
return isset($page_node->nid)) && $page_node->nid === $node->nidI agree that === is non standard and should be removed until we require type consistency in other places as well.
Comment #8
dawehnerHere it is
Comment #9
yched commentedI confirm that the patch fixes the bug in #658150-3: Nodereference D7 port.
That could be more specific. A node is "shown" in the frontpage listing too.
I'm also not sure that 'detail_page' is the right terminology for a node's node/%nid page. Then again, I'm not sure what the correct terminology would be, if we have any in core currently.
This is nitpick, I'm fine with the function name if moshe and Dries are OK with it.
Will set to RTBC once the PHPdoc is updtated.
This review is powered by Dreditor.
Comment #10
dawehnerWhat about node_is_own_pager?
Comment #11
dawehnerI wanted to say "node_is_own_page"
Comment #12
dries commentedLet's stick with detail_page and fix the phpDoc.
Comment #13
damien tournoud commentedThis is actually a duplicate of #445902: (bool) menu_get_object() is *not* an equivalent of $page, but I'll kill the other one instead.
One thing I don't really understand: why do we need that at all? Isn't that something that build modes should cover completely? Why do we need to make a difference between "A node displayed on a node/xxx page by itself" and "A full node displayed somewhere"?
Comment #14
damien tournoud commentedReading #658150-3: Nodereference D7 port, I understand why we need that. Shouldn't we refactor the node template file? We could have:
- node.tpl.php: the node without its title
- node-wrapper.tpl.php: a wrapper with the title
I don't really understand why we removed the $page parameter. After all, it *was* useful.
Comment #15
sunWhy not node_is_full_page() ?
Or if the consideration was that this clashes too much with the build mode, then why not even
node_is_page() ?
I'm on crack. Are you, too?
Comment #16
bleen commented+1 for node_is_page()
Comment #17
dries commented+1 for node_is_page() here too
Comment #18
dawehnernew version
Comment #19
yched commentedremark about PHPdoc in #9 still applies. Other than that, RTBC.
Comment #20
dries commentedLet's update the documentation, and get this committed! :)
Comment #21
bleen commentedhow bout this
Comment #22
aidanlis commentedAn aside, I don't like "I agree that === is non standard". As the author pointed out, it is significantly faster as it avoids running PHP's typecasting comparison. It really should be used by default, and avoids all sorts of nasty bugs like 0 == 'foo'.
Comment #23
sunPHPDoc summary should be on one line. Either shorten this or split it into a short summary and a separate description.
I don't really see how $page_node->nid could ever not be set if there is a $page_node. menu_get_object() can, however, return NULL or FALSE. Thus, I'd suggest to change the first condition to !empty($page_node).
This review is powered by Dreditor.
Comment #24
bleen commentedEDIT: ignore this patch ... forgot the "!"
Comment #25
bleen commenteduse this patch instead of #24
Comment #26
sunTypo in 'specific'... Also, 'this' is missing its context here.
However, since this is a simple helper function, we want to consolidate @return into the PHPDoc summary and remove @return.
"Returns whether the current page is the full page view of the passed in node."
We either want to drop the additional parenthesis around !empty() or wrap the entire ternary operator condition. The latter is preferred, because it clarifies where the condition starts and ends, and what is going to be returned.
I'm on crack. Are you, too?
Comment #27
bleen commentedComment #28
sunGreat - thank you
Comment #29
dries commentedI agree that this is great. Plus, it unblocks the work on nodereference. Committed to CVS HEAD.
Comment #30
damien tournoud commentedHm.
Comment #31
dries commentedI rolled back the patch. That empty() should probably be !empty().
Comment #32
bleen commentedblarrg!! Sorry about that.
Comment #34
bleen commentedI beg to differ, testbot.
Comment #36
dries commentedCommitted to CVS HEAD. Thanks.
Comment #37
damien tournoud commentedWe have one test failure that is probably related to this patch:
Comment #39
cburschkaI have traced that failure back to #654854: Clean up conditions in comment_reply(), avoid node_view() when unnecessary., actually. Aside from the chronology, there is also a clear reason for why that patch causes the failure (node is not displayed on comment reply page). So this issue is innocent.
Comment #41
gábor hojtsyUnfortunately this resulted in the critical issue that the same node now cannot be displayed in multiple build modes on its own page. Eg. a node cannot appear in both a summary/teaser block and its own full page at the same time. Both will render the full page: #721754: A node cannot be displayed in different view mode on its own page.