I've been able to get patTemplates to work with v1.1 Alpha. I took another look at the v1.1 patTemplate setup. The problem with getting patTemplate to work was with the J! template namespace. In JFactory::_createPatTemplate(), they set the namespace to jos but in the template files it's still mos. A temporary workaround is to add the mos namespace to your template object. I created a function to handle that. Here's the function I used:
Code: Select all
function addNamespace(&$tmpl, $name) {
$namespace = $tmpl->getNamespace;
if ( is_array($namespace) ) {
$namespace[] = $name;
} else {
$namespace = array($namespace, $name);
}
$tmpl->setNamespace($namespace);
return;
}
I call the addNamespace function in my createTemplate function:
Code: Select all
function &createTemplate($option) {
global $mosConfig_absolute_path;
$tmpl =& JFactory::_createPatTemplate();
$tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );
$options = array(
'output-xhtml' => true,
'clean' => true
);
$tmpl->applyOutputFilter( 'Tidy', $options );
$tmpl->useTemplateCache( 'File', array(
'cacheFolder' => dirname(__FILE__) . '/tmpl/tmplCache',
'lifetime' => 'auto' )
);
HTML_ectrader::addNamespace($tmpl, 'mos');
return $tmpl;
}
This method seemed to work ok. But once they change the namespace in the J! template files to jos, the easiest thing to do would be to change the namespace in your template files from mos: to jos:.
I think there may have been some confusion about the setNamespace function. The function doesn't change the namespace of existing template code. That is, mos: is still mos: as far as the reader is concerned. setNamespace only determines which namespace is parsed as a patTemplate token. Then if you use setNamespace to add a namespace mos:, it tells the reader to use both jos: and mos: when parsing template files.