function authcache_example_display_block_0 in Authenticated User Page Caching (Authcache) 6
Display user-customized block
2 calls to authcache_example_display_block_0()
- authcache_example_block in modules/
authcache_example/ authcache_example.module - Implementation of hook_block()
- _authcache_authcache_example in ajax/
authcache.php - Example of customized block info being returned
File
- modules/
authcache_example/ authcache_example.module, line 98 - authcache_example.module
Code
function authcache_example_display_block_0() {
global $user, $is_page_authcache;
if (!$user->uid) {
return 'Please login to test this block.';
}
else {
if ($is_page_authcache) {
// Use JS to retrieve block content
drupal_add_js(drupal_get_path('module', 'authcache_example') . '/js/authcache_example.js', 'module', 'header');
return ' ';
}
}
$block_text = check_plain(db_result(db_query("SELECT block_text FROM {authcache_example} WHERE uid = %d", $user->uid)));
$output = t("Hello, !user, this is a customized block of content that can be cached by the browser. Update it <a href=\"!url\">here</a>!", array(
'!user' => $user->name,
'!url' => url("user/{$user->uid}/authcache_example"),
));
$output .= "<p><strong class=\"error\">{$block_text}</strong></p>";
return $output;
}