koenox Posted August 10, 2011 Share Posted August 10, 2011 Hi all, I'm using Joomla 1.6 and during the construction of my website I turned of page caching. Upon finishing the site I turned caching back on and this act only messes up 1 of my pages. It's a tab script (SP Tab) in which I list the 6 products I sell on a different tab. The content of every tab is a seperate module. When I turn caching on (either progressive or conservative) then all 6 tabs show the same product (module). Since the php code of the script is kind of short and in this file it refers to caching, by posting the code here maybe you guys can tell me WHY on EARTH if I turn caching on, the tabs all show the same product. MANY thanks in advance. <?php /*--------------------------------------------------------------- # SP Tab - Next generation tab module for joomla # --------------------------------------------------------------- # Author - JoomShaper http://www.joomshaper.com # Copyright (C) 2010 - 2011 JoomShaper.com. All Rights Reserved. # license - PHP files are licensed under GNU/GPL V2 # license - CSS - JS - IMAGE files are Copyrighted material # Websites: http://www.joomshaper.com - http://www.joomxpert.com -----------------------------------------------------------------*/ // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); abstract class modspTabHelper { static function getTabs($params) { $mods = $params->get('mods'); $images = $params->get('images'); $options = array('style' => 'none'); $items = array(); for ($i=0;$i<count($mods);$i++) { $items[$i]->order = modspTabHelper::getModule($mods[$i])->ordering; $items[$i]->title = modspTabHelper::getModule($mods[$i])->title; $items[$i]->content = JModuleHelper::renderModule( modspTabHelper::getModule($mods[$i]), $options); } return $items; } //Load Module by id static function getModule($id) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $lang = JFactory::getLanguage()->getTag(); $clientId = (int) $app->getClientId(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, title, module, position, ordering, content, showtitle, params'); $query->from('#__modules AS m'); $query->where('m.published = 1'); $query->where('m.id = ' . $id); $date = JFactory::getDate(); $now = $date->toMySQL(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = '.$db->Quote($nullDate).' OR m.publish_up <= '.$db->Quote($now).')'); $query->where('(m.publish_down = '.$db->Quote($nullDate).' OR m.publish_down >= '.$db->Quote($now).')'); $query->where('m.access IN ('.$groups.')'); $query->where('m.client_id = '. $clientId); // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')'); } $query->order('position, ordering'); // Set the query $db->setQuery($query); $cache = JFactory::getCache ('com_modules', 'callback'); $cacheid = md5(serialize(array($groups, $clientId, $lang))); $module = $cache->get(array($db, 'loadObject'), null, $cacheid, false); if (!$module) return null; $file = $module->module; $custom = substr($file, 0, 4) == 'mod_' ? 0 : 1; $module->user = $custom; $module->name = $custom ? $module->title : substr($file, 4); $module->style = null; $module->position = strtolower($module->position); $clean[$module->id] = $module; return $module; } } Quote Link to comment https://forums.phpfreaks.com/topic/244396-caching-pages-messes-up-my-tab-script-in-joomla/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.