function _panopoly_widgets_content_item_title_rewrite in Panopoly Widgets 7
Rewrites the node title by poisening the node_load() static cache.
We use this to support overriding the title of 'Content item' widgets. Unfortunately, we can't hook into a spot between when the View loads the entity and Panelizer renders it, so we have to use this hack.
Parameters
int $nid: The NID of the node whose title we're going to rewrite.
string|NULL $title: (optional) If a string is given, the this is the new title for the node. If NULL is given, return the title to its previous value.
See also
panopoly_widgets_views_post_execute()
panopoly_widgets_views_post_render()
2 calls to _panopoly_widgets_content_item_title_rewrite()
- panopoly_widgets_views_post_execute in ./
panopoly_widgets.module - Implements hook_views_post_execute().
- panopoly_widgets_views_post_render in ./
panopoly_widgets.module - Implements hook_views_post_render().
File
- ./
panopoly_widgets.module, line 654
Code
function _panopoly_widgets_content_item_title_rewrite($nid, $title = NULL) {
static $saved_title = array();
$node = node_load($nid);
if (!is_null($title)) {
$saved_title[$nid] = $node->title;
$node->title = $title;
}
elseif (isset($saved_title[$nid])) {
$node->title = $saved_title[$nid];
}
}