T3 framework file structure & what are they doing
Since I can't get support from Gavick Pro-you can't post in their forum unless you pay money for that, then I will have to figure out the logic of the program and the organization of files.
So let's roll off...........
The entry point of this template is still index.php under \templates\gk_sporter\ directory, and for now, even I don't understand all the PHP code inside it, but we can say that the main point that initiate the process of outputting HTML is the call to display():
$layout = $tmpl->getLayout();
if ($layout)
{
$tmpl->display($layout);
}
And the variable $tmpl is an instance of GKTemplateHelper, from the first few lines of code:
include_once (dirname(__FILE__).DS.'libs'.DS.'gk.template.helper.php');
$tmpl = GKTemplateHelper::getInstance($this, array('ui', GK_TOOL_SCREEN, GK_TOOL_MENU, 'main_layout', 'direction'));
So we go to gk.template.help.php, to dig the logics behind out, and here is the function call flow:
At the moment, I am just curious about the content held by $layoutpath, so add code
dump( $layoutpath, 'layoutpath' );
into the function body, but before that make sure you have JDump plug-in installed. And the result goes:
Actually, that output is produced by multiple calls to the function_load(). Why is that? Just comment out the include directive:
function _load ($layout)
{
if (($layoutpath = $this->layout_exists ($layout)))
{
//dump( $layoutpath, 'layoutpath' );
var_dump($layoutpath);
//include ($layoutpath);
}
}
then the output is only one line:
string(64) "C:\xampp\htdocs\joomla!\templates\gk_sporter\layouts\default.php"
it is because inside gk_sporter\layouts\default.php, there are many calls like:
$this->loadBlock('head');
and that will result in the include statements be executed again and again, here is the call flow:
And that explains how T3 framework assembly different blocks, and take a look at blocks\head.php:
<?php if($this->_tpl->params->get("chrome_frame")) : ?>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<?php endif; ?>
<jdoc:include type="head" />
<?php JHTML::_('behavior.mootools'); ?>
<?php if (!$this->isIE6()) : ?>
<?php
$document =& JFactory::getDocument();
$headData = $document->getHeadData();
$scripts_array_keys = array_keys($headData['scripts']);
$headData['scripts'] = array();
foreach($scripts_array_keys as $key){
$headData['scripts'][$key] = 'text/javascript';
if(preg_match('/mootools.js/',$key)) {
$headData['scripts'][$this->templateurl().'/js/domready_fix.js'] = 'text/javascript';
}
}
......
there is one Joomla! function, which is <jdoc:include type="head" />, that shows how T3 and Joomla! cooperate together. In the above piece, the head block still uses Joomla! template's global information to faciliate the loading of the head part of an HTML page, such as javascript, CSS and so on........
Apart from that, inside the block, there are calls that specific to the template:
......
<?php if (($gkmenu = $this->loadMenu())) $gkmenu->genMenuHead (); ?>
<?php $this->loadBlock('cufon'); ?>
......
and it may load other block files. So that is why I said the output by JDump is due to mutiple calls of_load(). By adding the express
var_dump($layoutpath);
before
include ($layoutpath);
we can get an output that shows up the block file's path immediate above its content, and eventually the output html block is sliced up by the string generated by var_dump() function, that providing much convenience for further study.
Block in T3 framework & how block works
In T3, block is one brand-new concept introduced----to provide higher flexiblity.Blocks are similar to positions in Joomla!, but they are at different hierarchical level, in terms of capacities of accommodating HTML output. All T3 templates are cut up into blocks, one block can contain other blocks, or just contain positions of Joomla!, the following is the default structure of the template based on T3 framework.
and the following is sporter template's layout(from help document):
At this point, we come to the problem, that is how do this two layouts work together, or say what is the relationship between them? In gk_sporter\layouts\default.php, this file contains this piece of code:
$positions = array (
'left1' =>'left1',
'left2' =>'left2',
'left-mass-top' =>'left_top',
'left-mass-bottom' =>'left_bottom',
'right1' =>'right1',
'right2' =>'right2',
'right-mass-top' =>'right_top',
'right-mass-bottom' =>'right_bottom',
'content-mass-top' =>'top',
'content-mass-bottom' =>'bottom',
'content-top' =>'adv_top',
'content-bottom' =>'adv_bottom',
'inset1' =>'inset1',
'inset2' =>'inset2'
);
this snippet declares an array named $position, and assigns it to some position names, actually, the keys of array are block names in T3 template, and the values are position names in Joomla!. This array is used to keep track of which position modules in Joomla! do you want to put on each block in T3 template. As shown:
Please note that, althought the $position defines all the blocks shown in T3 default template, it only includes the positions of Sporter partially( the ones embraced in MAIN square in the following figure ). And now, let's map the positions in sporter template to the blocks in T3, indeed the block's name is refered as the php files(for example, to load top block will actually include top.php):
And take nav.php as example, open it in easyEclipse to inspect how it include the positions:breadcrumb,top_nav,menu and highlighter.
In summary, you can change the $position array its element values, to change the position of the modules, or you can even rearrange the php statement of loading blocks if you like, but that should not be the original aim of T3 developers.
A blog:
http://viiiix.com/joomla-documentation/ja-template-framework-guides
A forum:
http://www.joomlagate.com/forum/