in reference to the following documentation for hook_page_alter :

  // Node body.
  $page['content']['nodes'][$nid]['body']
  // Array of links attached to the node (add comments, read more).
  $page['content']['nodes'][$nid]['links']
  // The node object itself.
  $page['content']['nodes'][$nid]['#node']
  // The results pager.
  $page['content']['pager']

Could the structure happen to be the following?

$page['content']['system_main']['nodes']...

CommentFileSizeAuthor
#6 975806.patch933 bytesamateescu
#3 screenshot_034.png5.68 KBchx
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

I don't know -- are you asking a question or saying the documentation is incorrect?

nlambert’s picture

I'm suggesting that the documentation might be incorrect. I believe the node structure might be :

$page['content']['system_main']['nodes']... etc

I stumbled onto this while "moving" the advanced search form to another block... (the search form being within the same array as the nodes)

function cdm_page_alter(&$page) {
if (arg(0) == 'search' && arg(2)) {
$page['title_region']['search_form'] = $page['content']['system_main']['search_form'];
unset($page['content']['system_main']['search_form']);
}
}

chx’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
5.68 KB

That's correct.

jhodgdon’s picture

Title: Documentation problem with hook_page_alter » hook_page_alter() documentation shows incorrect $page structure.
Priority: Minor » Normal
Issue tags: +Novice

OK, thanks! The hook_page_alter() documentation needs to be updated then. This would be a good project for a novice doc/patch contributor.

nlambert’s picture

I'm fairly new to this :-)
I guess I can start by reading...
http://drupal.org/contribute/documentation

amateescu’s picture

Status: Active » Needs review
FileSize
933 bytes

This should do it.

@modesia, I suggest you read this also: http://drupal.org/node/707484

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks reasonable to me, given the screen shot chx gave and the suggestion from the person who reported this issue.

amateescu’s picture

jhodgdon, I also tested this with dsm($page) in a hook_page_alter implementation and chx's screenshot is right.

jhodgdon’s picture

Good. :)

nlambert’s picture

thanks amateescu, that documentation will definitely speed things up!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch!

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Novice

Automatically closed -- issue fixed for 2 weeks with no activity.