Active
Project:
Boost
Version:
7.x-1.x-dev
Component:
Caching logic
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Jan 2018 at 14:51 UTC
Updated:
10 Jan 2018 at 07:02 UTC
Jump to comment: Most recent
TinyBox does not work for anonymous users.
When I flush the cache for the front page, where it shows up several time, I sometime succeed at getting anonymous users seeing the tinybox splashing correctly for some time (10-30 minutes)
Then, no splashing occurs anymore. Looking at the code page, both the js script and the inline code are absent.
The code is rather simple :
function tinybox_init() {
// Necessary to check if we're on the frontpage
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$tinybox_content = "";
$tinybox_splash_source_value = variable_get('tinybox_splash_source_value', '');
$tinybox_front = variable_get('tinybox_front', 0);
if ($tinybox_splash_source_value && ((drupal_is_front_page() && $tinybox_front == 1) || $tinybox_front == 0)) {
$tinybox_splash_source_type = variable_get('tinybox_splash_source_type', 'nid');
$tinybox_splash_delay = variable_get('tinybox_splash_delay', 0);
if ($tinybox_splash_delay) {
if (!isset($_SESSION['tinybox_splash_session_time'])) {
$_SESSION['tinybox_splash_session_time'] = time();
}
if ((time() - $_SESSION['tinybox_splash_session_time']) <= $tinybox_splash_delay) {
return;
}
else {
$_SESSION['tinybox_splash_session_time'] = time();
}
}
$tinybox_splash_autohide = variable_get('tinybox_splash_autohide', 0);
$tinybox_splash_css = variable_get('tinybox_splash_css', '');
$tinybox_splash_css = ($tinybox_splash_css == '') ? drupal_get_path('module', 'tinybox') : $tinybox_splash_css;
$tinybox_front = variable_get('tinybox_front', 0);
drupal_add_js('sites/all/libraries/tinybox/tinybox.js', 'module');
drupal_add_css($tinybox_splash_css .'/tinybox.css');
if ($tinybox_splash_source_type == 'nid') {
$node = node_load($tinybox_splash_source_value);
$tinybox_content = str_replace(chr(13), '', $node->body);
$tinybox_content = str_replace(chr(10), '', $tinybox_content);
}
if ($tinybox_splash_source_type == 'content_type') {
$sql = "SELECT nid FROM {node} n WHERE n.type = '%s' AND n.status=1 ORDER BY n.created DESC";
$results = db_query_range($sql, $tinybox_splash_source_value, 0, 1);
$data = db_fetch_object($results);
$node = node_load($data->nid);
$tinybox_content = str_replace(chr(13), '', $node->body);
$tinybox_content = str_replace(chr(10), '', $tinybox_content);
}
if ($tinybox_splash_source_type == 'views') {
if (module_exists('views')) {
$view = views_get_view($tinybox_splash_source_value);
if ($view) {
$view->preview('default');
if (count($view->result)) {
$tinybox_content = $view->render();
}
}
else {
$tinybox_content = 'Views not found: ' . $tinybox_splash_source_value;
}
}
else {
$tinybox_content = t('Require Views module.');
}
$tinybox_content = str_replace(chr(13), '', $tinybox_content);
$tinybox_content = str_replace(chr(10), '', $tinybox_content);
}
$tinybox_splash_width = variable_get('tinybox_splash_width', '');
$tinybox_splash_height = variable_get('tinybox_splash_height', '');
$tinybox_splash_width = ($tinybox_splash_width == '') ? 0 : $tinybox_splash_width;
$tinybox_splash_height = ($tinybox_splash_width == '') ? 0 : $tinybox_splash_height;
if (!empty($tinybox_content)) {//display Tinybox only if some content is present
drupal_add_js('
window.onload = function() {
TINY.box.show({
html: \'' . $tinybox_content . '\',
boxid:\'tbox\',width:' . $tinybox_splash_width . ',height:' . $tinybox_splash_height . ',fixed:false,
maskid:\'blackmask\',maskopacity:40,
autohide:' . $tinybox_splash_autohide . ',
closejs:function(){closeJS()}
});
document.getElementsByClassName(\'tmask\')[0].onclick=null;
}
', 'inline');
}
}
}
Thanks for help
Comments
Comment #2
jvieille commentedComment #3
jvieille commentedI changed
function tinybox_init() {
by
function tinybox_exit() {
That seems to fix it.
Is this a correct way, or a hack hidding something else wrong?