function authcache_poll_node_view_alter in Authenticated User Page Caching (Authcache) 7.2
Implements hook_node_view_alter().
Replace poll form and result view with a span which will be populated with its actual content during the ajax phase.
File
- modules/
authcache_poll/ authcache_poll.module, line 49 - Authcache support for poll module.
Code
function authcache_poll_node_view_alter(&$build) {
$node = $build['#node'];
if ($node->type === 'poll' && authcache_page_is_cacheable()) {
if (isset($build['poll_view_voting'])) {
authcache_p13n_attach($build['poll_view_voting'], array(
'#theme' => 'authcache_p13n_fragment',
'#fragment' => 'poll-view',
'#param' => $node->nid,
'#fallback' => 'cancel',
));
}
if (isset($build['poll_view_results'])) {
$router_item = menu_get_item();
$fragment = $router_item['page_callback'] === 'poll_results' ? 'poll-result' : 'poll-view';
authcache_p13n_attach($build['poll_view_results'], array(
'#theme' => 'authcache_p13n_fragment',
'#fragment' => $fragment,
'#param' => $node->nid,
'#fallback' => 'cancel',
));
}
}
}