Currently node_view.inc does not execute the normal Drupal hooks, e.g. hook_node_view and hook_entity_view. In order for several other modules to work correctly, e.g. Metatag, these hooks must be executed.


Original request:

Currently the node_content.inc plugin uses node_invoke($node, 'view') to trigger node_view(), which means that several key node-related and entity-related hooks do not get triggered unless that pane is added to the page. Several modules, include Metatag, depend on entity hooks triggering on entity view pages, which won't happen. I suggest moving the entity/node view logic to node_view.inc, and trim the node_content.inc logic to just building the final output.

Files: 
CommentFileSizeAuthor
#13 ctools-n1760384-13-d7.patch2.12 KBmeba
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]
#12 ctools-n1760384-12-d7.patch2.12 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]
#11 ctools-n1760384-11-d7.patch2.12 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]
#10 ctools-n1760384-10-d7.patch2.01 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]
#9 ctools-n1760384-9-d7.patch2.08 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]
#7 ctools-n1760384-7-d7.patch1.4 KBDamienMcKenna
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

Comments

That doesn't work; the node_invoke call can do a lot of modifications to the node that are necessary for that rendering, so simply moving it is not an option.

Title:Move hook_node_view implementation to node_view.incUpdate node_view.inc to execute the normal Drupal hooks

I've updated the title to clarify the task.

Component:Code» Page Manager

This is a Page Manager thing.

Category:feature» bug

Status:Active» Needs review
StatusFileSize
new1.4 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

This patch clones most of the code from node_view_multiple() in order to trigger the appropriate hooks.

StatusFileSize
new2.08 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

A slight variation of #7 that moves the generic core snippets to the top of the function and the CTools custom code underneath.

StatusFileSize
new2.01 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

A huge simplification of the code by just running node_page_view() at the beginning, and storing its output for later in case it's needed.

StatusFileSize
new2.12 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

Some updated comments, functionally it is identical to #10.

StatusFileSize
new2.12 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

A small tweak to the last patch that removes the $function variable as it is no longer needed.

StatusFileSize
new2.12 KB
PASSED: [[SimpleTest]]: [MySQL] 67 pass(es).
[ View ]

The patch did not apply anymore. I rerolled it and also confirmed that once applied Meta Tags start showing on Panel pages that are not using full rendered output

Status:Needs review» Needs work

This needs some additional work, it should also trigger the page title handling.

Status:Needs work» Needs review

Never mind, I think I found the solution for the page titles in #1732538: Page title pattern ignored. Pushing this back for review.

This patch (from #13) did not have any effect on my setup. The meta tags (from metatag.module) did not show up on my node.

Meta tags 7.x-1.0-alpha8
Ctools 7.x-1.2
Panels 7.x-3.0
Panels everywhere 7.x-1.0-rc1

@Peter: Please try the -dev version of Metatag.

@Peter: also note that currently the page title is not overridden correctly, I'm working separately to resolve that (#1732538: Page title pattern ignored), so please check the description and other tags.

Patch from #13 gave me the following error:

    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/username/public_html/h/mydomain.com/includes/entity.inc).
    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of /home/username/public_html/h/mydomain.com/includes/entity.inc).

Redownloading 1.x-dev from 2012-Oct-11 makes the error go away, so definitely something with the patch...

Hope to see something working between this and metatags soon : )

Oh, I forgot to mention that I'm using the metatag-1.x-dev-[2012-Oct-16] and I'm still not having any luck with the metatag description after applying patch #13 : (

Patch #13 don't work with :
ctools (7.x-1.2) + metatag 7.x-1.0-beta1
or latest dev versions of ctools+metatag

Also the patch breaks conditionals in webform 7.x-4.0-alpha6
The div id's are changed from : id="xxx-1" to: id="x--2-1"
Seems like node_page_view($node) are invoked twice

Status:Needs review» Needs work

@Thelmer: when you say it "didn't work", what meta tags did you check and entity page were you viewing (taxonomy term, node, etc)?

Status:Needs work» Needs review

Hi Damien

I'm trying with node pages displayed with panels.
I have only been looking at the description meta data.

After some more testing I have seen that it actually works with 1.2+beta1 on regular nodes but not on the one I use for the front page. For now I can set the description here with the global metadata settings for the frontpage.

I still see the prblem with webform conditionals.

@thelmer: sorry, I got mixed up between this and another issue.

I'll have to look into Webform.

patch in #13 worked for me to add metatag keywords on to a node overridden by panels.. thanks a lot guys.

Works for me as well.

Patch in #13 works for me in that it adds meta tags to a node overridden with a panel. Thanks!

Meta tags 7.x-1.0-alpha8
Ctools 7.x-1.2
Panels 7.x-3.3

@DamienMcKenna:

After updating I no longer seem to need this patch anymore. Everything works fine.

Drupal 7.22 (from 7.16)
ctools 7.x-1.3 (from 7.x-1.2)
metatag 7.x-1.0-beta5 (from 7.x-1.0-alpha8)
panels 7.x-3.3 (not updated)

The patch is no longer strictly needed as I built some workarounds in Metatag.

That said, I still think the change to CTools is worthwhile as it should be triggering the correct hooks.

I have a project with logic in hook_node_view that is needed and not being executed for panel pages. I'm going to give this patch a shot to see if it solves the issue.

Issue summary:View changes

Rewrote the description.

Issue summary:View changes
Status:Needs review» Reviewed & tested by the community

Patch in #12 applied and worked great. Thanks @DamienMcKenna!