Bug in patTemplate.php?

A general technical discussion area for patTemplate.
Locked
User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Bug in patTemplate.php?

Post by musicones » Mon Nov 07, 2005 10:16 am

Hi,

after I've changed my project to use Jfactory I get following error:
Fatal error: Call to a member function on a non-object in D:\Entwicklung\apachefriends\xampp\htdocs\joomla11SVN\libraries\pattemplate\patTemplate.php on line 242
Have I done something wrong in calling patTemplate, or is this a bug?

regards
musicones

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: Bug in patTemplate.php?

Post by alwarren » Mon Nov 07, 2005 1:38 pm

I haven't tried patTemplate with SVN yet. What version of Joomla are you trying to use patTemplate with?
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: Bug in patTemplate.php?

Post by musicones » Mon Nov 07, 2005 3:47 pm

Hi alwarren,

I always use latest JoomlaSVN Version, like I have written in last Thread "Difference of patTemplate in 1.1"
Since they have changed to Jfactory I can't use it anymore.

regards
musicones

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: Bug in patTemplate.php?

Post by alwarren » Tue Nov 08, 2005 7:10 am

There seems to be a considerable amount of working going on around patTemplate in svn 1.1. I've been unable to get it to work using current (1.0.3) methods. Guess we'll have to wait until the devs are finished and we get word to test things.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: Bug in patTemplate.php?

Post by alwarren » Wed Nov 09, 2005 2:46 pm

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.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW


Locked

Return to “patTemplate”