Hello,
I've been making some tests and have a solution that you can try. It works slightly different from what you described but the main idea is the same. Initially, only the contents of a first tab is loaded. Then, when you click any other tab, its content is being loaded. Not all other tabs at once but each tab separately when needed. And it's only for the first click, there are no additional reloads if a user clicks this tab again.
In order to do it you need to create additional layout for your item type. This layout should contain only positions for your tabs except for the first tab. And when you click a tab from your full layout, contents of a corresponding tab from this layout will be loaded.
I'll describe what I did so you can repeat it if needed. In this example I'll modify a standard JBZoo demo website with latest updates. Item type is "Product".
1. Create a new layout for this item type
First we should go to media/zoo/applications/jbuniversal/templates/catalog/renderer/item/product . Here I made a copy of full.php and called it loaded.php. After that I removed everything except last four tabs:
This is how my file looks like:
<?php
/**
* JBZoo is universal CCK based Joomla! CMS and YooTheme Zoo component
* @category JBZoo
* @author smet.denis <admin@joomla-book.ru>
* @copyright Copyright (c) 2009-2012, Joomla-book.ru
* @license http://joomla-book.ru/info/disclaimer
* @link http://joomla-book.ru/projects/jbzoo JBZoo project page
*/
defined('_JEXEC') or die('Restricted access');
$positionParams = array(
'style' => 'jbblock',
'tag' => 'div',
'labelTag' => 'h3',
'clear' => true
);
?>
<div id="tab-gallery"><?php echo $this->renderPosition('tab-gallery', $positionParams); ?></div>
<div id="tab-properties"><table class="jbtable"><?php echo $this->renderPosition('tab-properties', array('style' => 'jbtable')); ?></table></div>
<div id="tab-reviews"><?php echo $this->renderPosition('tab-reviews', $positionParams); ?></div>
<div id="tab-comments"><?php echo $this->renderPosition('tab-comments', $positionParams); ?></div>
Then we should add information about this layout and its positions to metadata.xml and positions.xml:
metadata:
<layout name="loaded">
<name>Loaded</name>
<description>Layout for loading tabs content</description>
</layout>
positions:
<positions layout="loaded">
<position name="tab-gallery">Tab: gallery</position>
<position name="tab-properties">Tab: properties</position>
<position name="tab-reviews">Tab: reviews</position>
<position name="tab-comments">Tab: comments</position>
</positions>
Then we should assign elements to these new positions:
2. Modify full.php
Here we should remove conditions for displaying tabs and tabs navigation, as well as content rendering of all tabs except the first one. We should keep only wrappers of other tabs. Here is the part of my full.php that creates tabs:
<?php
$positionParams = array(
'style' => 'jbblock',
'tag' => 'div',
'labelTag' => 'h3',
'clear' => true
);
?>
<div id="<?php echo $tabsId;?>" class="rborder">
<ul>
<li>
<a href="<?php echo $this->app->jbenv->getCurrentUrl(); ?>#tab-text"><?php echo JText::_('JBZOO_ITEM_TAB_DESCRIPTION'); ?></a>
</li>
<li>
<a href="<?php echo $this->app->jbenv->getCurrentUrl(); ?>#tab-properties"><?php echo JText::_('JBZOO_ITEM_TAB_PROPS'); ?></a>
</li>
<li>
<a href="<?php echo $this->app->jbenv->getCurrentUrl(); ?>#tab-gallery"><?php echo JText::_('JBZOO_ITEM_TAB_GALLERY'); ?></a>
</li>
<li>
<a href="<?php echo $this->app->jbenv->getCurrentUrl(); ?>#tab-reviews"><?php echo JText::_('JBZOO_ITEM_TAB_REVIEWS'); ?></a>
</li>
<li>
<a href="<?php echo $this->app->jbenv->getCurrentUrl(); ?>#tab-comments"><?php echo JText::_('JBZOO_ITEM_TAB_COMMENTS'); ?>
(<?php echo $item->getCommentsCount(); ?>)</a></li>
</ul>
<div id="tab-text"><?php echo $this->renderPosition('tab-text', $positionParams); ?></div>
<div id="tab-properties"></div>
<div id="tab-gallery"></div>
<div id="tab-reviews"></div>
<div id="tab-comments"></div>
</div>
<?php $this->app->jbassets->tabs(); ?>
<script type="text/javascript">
var openedtabs = new Array();
openedtabs[0] = true;
currenturl=document.URL;
jQuery(function ($) {
$('#<?php echo $tabsId;?>').JBZooTabs({
onTabShow: function (index) {
var map = $('.googlemaps > div:first');
if (map.length) {
map.data('Googlemaps').refresh();
}
if (openedtabs[index] != true) {
var tab = $('#<?php echo $tabsId;?> > div').eq(index);
var tabid = tab.attr('id');
targeturl = currenturl + '?tmpl=component&jbquickview=loaded' + ' #' + tabid;
tab.load(targeturl);
openedtabs[index] = true;
}
}
});
});
</script>
Notice that I only included the part with the tabs, this is not a complete file.
If you compare this code to the original one, you'll notice that a lot of code was removed. But some things were added to the tabs initialization script.
This should work fine for basic content, but there might be problems if you need to load something complex. So you should test it on your website.
Edited by Kess, 22 December 2013 - 03:01.