How to use the patTemplate in joomla!

A general technical discussion area for patTemplate.
alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: How to use the patTemplate in joomla!

Post by alwarren » Sat Oct 22, 2005 4:51 pm

There's at least one issue that I'm aware of. The translate function has been highly modified to work with a $_LANG object instead of using the standard pat translation method. $_LANG needs to have a function named _ - ie: 

Code: Select all

function _($string) {
	// logic to translate string goes here
	return $translatedValue;
}
I've had trouble with one of the patFactory templates (specific to Joomla) - include-tabs. There is a style block that uses a {TABURL} variable for a path to graphics. I couldn't get it to work. So, I just created a new mosTabs object whose constructor plugs in the appropriate scripts and css things. It seems to work fine.

BTW, patFactory::createTemplate creates a number of handy templates you can use to make life easier. Try creating a template with it then do a dump() and take a look at all the included templates. You can use to render any of those templates.
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: How to use the patTemplate in joomla!

Post by alwarren » Sat Oct 22, 2005 4:52 pm

There's at least one issue that I'm aware of. The translate function has been highly modified to work with a $_LANG object instead of using the standard pat translation method. $_LANG should be global and needs to have a function named _ - ie: 

Code: Select all

function _($string) {
	// logic to translate string goes here
	return $translatedValue;
}
I've had trouble with one of the patFactory templates (specific to Joomla) - include-tabs. There is a style block that uses a {TABURL} variable for a path to graphics. I couldn't get it to work. So, I just created a new mosTabs object whose constructor plugs in the appropriate scripts and css things. It seems to work fine.

BTW, patFactory::createTemplate creates a number of handy templates you can use to make life easier. Try creating a template with it then do a dump() and take a look at all the included templates. You can use to render any of those templates.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

emeyer
Joomla! Explorer
Joomla! Explorer
Posts: 352
Joined: Thu Sep 29, 2005 2:37 am

Re: How to use the patTemplate in joomla!

Post by emeyer » Sat Oct 22, 2005 6:08 pm

Thanks for the info!  I'd like very much to use a pattemplate in a content item---so I dont need to build an entire component!

Do you know anything about a mambot for pattemplate, so they can be included in content items? It's mentioned but I can't anything more about it. Or should this be done some other way?

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

Re: How to use the patTemplate in joomla!

Post by alwarren » Wed Oct 26, 2005 2:28 pm

I found another issue with patTemplates. When I'm done posting here, I'll check the pat forum to see if it's being addressed.

When you add an array to a template, say you're using a template with your $rows array, it will loop automatically. Now, say you're using a condition and one of your sub conditions is __first. The __first sub condition will only output on the first iteration of your array. But, In patTemplates 3.1.0, there is a new undocumented sub condition called __single. The problem is, if sometimes your $rows array only contains a single value, __first fails. So, you have to add a __single sub template and duplicate everything that's in your __first sub template. It makes things a little messy and adds un-needed redundancy.

I ran across this when I added pageNav to my component. I have a form that only displays on the first iteration of my $rows array. What I discovered was that when a page only contains a single record, the form wasn't displaying. This little bug is going to cause major problems working with pageNav if you need to use the __first sub condition.

As an example, suppose you have added a $rows variable to a template named "rows". Here is an example template:

Code: Select all

<mos:tmpl name="rows">
   <mos:Call template="rowstemplate"/>
   <mos:tmpl name="formcondition" type=condition conditionvar="rows.rowid">
      <mos:sub condition="__first">
         <mos:Call template="formtemplate"/>
          This fails if there is only one record in $rows
      </mos:sub>
      <mos:sub condition="__single">
         <mos:Call template="formtemplate"/>  <--- redundant
          This works if there is only one record in $rows
      </mos:sub>
   </mos:tmpl
</mos:tmpl>
Note how __first fails if there is only one record in $rows and how we had to add __single to make things work.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

brandonjp
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Fri Aug 04, 2006 9:12 pm

Re: How to use the patTemplate in joomla!

Post by brandonjp » Tue Jan 16, 2007 3:38 am

I'm trying to understand the whole 'patTemplate' thing...I've been reading the docs and such but while trying to install a suckerfish menu that incorporates patTemplate - i kept getting this error:
Warning: renderasstring(/home/www/svsbedford.org/svsweb/includes/patTemplate/patTemplate.php): failed to open stream: No such file or directory in /home/www/svsbedford.org/svsweb/modules/mod_exmenu/exmenu/view/pattemplate.menuview.class.php on line 28

Fatal error: renderasstring(): Failed opening required '/home/www/svsbedford.org/svsweb/includes/patTemplate/patTemplate.php' (include_path='.:/usr/local/lib/php') in /home/www/svsbedford.org/svsweb/modules/mod_exmenu/exmenu/view/pattemplate.menuview.class.php on line 28
sure enough, there's nothing on my server located in the joomla structure at 'includes/patTemplate'
should there be?  is something just screwed up with my joomla installation?

or is patTemplate something i need to download and install??

i'm trying out Joomla 1.5 at:
http://www.svsbedford.org/svsweb

thanks
--bp

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3763
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: How to use the patTemplate in joomla!

Post by Hackwar » Tue Jan 16, 2007 10:42 am

patTemplate has been deprecated and will not be used in Joomla anymore. The engine is still left in place fpr backwards compatibility reasons.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

focus2def
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Feb 06, 2007 9:55 pm

Re: How to use the patTemplate in joomla!

Post by focus2def » Tue Feb 06, 2007 10:07 pm

If patTemplate is not being used anymore, then how do I get past the issue that Brandonjp is having.  I have the exact same issue trying to use a suckerfish menu.  Any advice is greatrly appreciated, thanks!

ziad
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Sun Nov 26, 2006 12:48 pm
Location: London

Re: How to use the patTemplate in joomla!

Post by ziad » Wed Apr 11, 2007 12:07 pm

Hackwar wrote: patTemplate has been deprecated and will not be used in Joomla anymore. The engine is still left in place fpr backwards compatibility reasons.
WHAT?!? I've just started working with Joomla a while ago and was under the impression that patTemplate would be the presentation layer for Joomla and have spent a substantial amount of time/energy trying to figure out how to do things in patTemplate and then I come across this!!!

Why has patTemplate been dumped? I didnt think patTemplate was the best presentation engine to use (I prefer smarty) but was starting to get the hang of it. If patTemplate is not being used, what will be the presentation layer?

dynedain
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Wed Aug 24, 2005 7:20 pm
Location: Los Angeles
Contact:

Re: How to use the patTemplate in joomla!

Post by dynedain » Wed Apr 11, 2007 4:38 pm

Sad, but true.

The developers of Joomla after attempting to use patTemplate on some of the core components realized that the performance hit was to great.

It's not being stripped out of 1.5, so you're safe for the time being. At the earliest it would be removed is 2.0... and considering how long 1.5 has been in development, I think you have several years before worrying about 2.0  ;)

The new recommendation for components is the object-oriented programming technique Model-View-Controller (MVC). While the old methods will still work, MVC will be much more efficient for implementing complex components. It appears at the moment, you can build the View portion of your component however you want, and additional templates for your components by implementing additional Views.

So in this scenario, the View part of the component is the presentation layer and is just plain ol' PHP, so you can have as little or as much logic in the presentation layer as you need. Of course you could continue to use patTemplate in 1.5 by implementing it in your Views, but it will eventually be phased out.

Terenzusum
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 189
Joined: Thu Aug 18, 2005 4:07 pm
Contact:

Re: How to use the patTemplate in joomla!

Post by Terenzusum » Wed Apr 11, 2007 5:57 pm

pattemplate is obsolete and this is fact 

there are lots of time till 1.5 goes stable, so only the laziest ones or missinformed will use obsolete pattemplate

till 1.5 is in beta we can and must remove a lot of bad things, one of them is obsolete pattemplate  :-*

If you want spent lots of money on your hosting solution or see your site off line then use obsolete pattemplate
Poll [ Homepage: http://www.bertran.uni.cc/ORION ]
Why there are no updates on the current donation and add revenue status? helping out Joomla! users, "giving back" to the community...
Testing Joomla! 1.5 beta 2 SVN on http://bertran.uni.cc/j15b2

User avatar
ChiefGoFor
Joomla! Champion
Joomla! Champion
Posts: 5589
Joined: Tue Sep 13, 2005 12:22 am
Location: Omaha, Nebraska, USA
Contact:

Re: How to use the patTemplate in joomla!

Post by ChiefGoFor » Wed Apr 11, 2007 6:08 pm

@Terenzusum
Yes, patTemplates is obsolete, but for backwards compatibility reasons, it will stay in with the 1.5 release as Hackwar stated a few posts above. If you do not like it, then remove it after you download it. I am curious though, can you please elaborate on your statement:
Terenzusum wrote: If you want spent lots of money on your hosting solution or see your site off line then use obsolete pattemplate
How will patTemplates cost you money and how can it cause your site to be offline?
Kenneth Crowder - Omaha, Nebraska, USA
Global Moderator - Joomla! ...because open source matters
"Try to answer two questions for every one question you ask." - Me

User avatar
masterchief
Joomla! Hero
Joomla! Hero
Posts: 2316
Joined: Fri Aug 12, 2005 2:45 am
Location: Brisbane, Australia
Contact:

Re: How to use the patTemplate in joomla!

Post by masterchief » Wed Apr 11, 2007 9:17 pm

Ok.

patTemplate is still a very fine templating engine, in fact I absolutely love the syntax over any other system - it's certainly not obsolete in terms of a tools that's available to use.

However, it does have a significant performance hit (although, page caching would help that) and it still has few painful quirks (like nested loops are a pain in the rear to implement) and sometimes it refuses to do what you think it should.

Sadly, and I fought this decision for a long time,  I've had to resign to the fact that I need to go back to the php way of doing things and am currently un-patTemplating all my layout files.  It's not too bad or hard - in some ways it's a lot nicer and you get a lot more control, particularly with heavily nested loops.  In other ways it's not as nice but that's the way the cookie crumbles.
Andrew Eddie - Tweet @AndrewEddie
<><
http://eddify.me
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.

Terenzusum
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 189
Joined: Thu Aug 18, 2005 4:07 pm
Contact:

Re: How to use the patTemplate in joomla!

Post by Terenzusum » Wed Apr 11, 2007 9:35 pm

I think masterchief answered your question, didnt he?
Poll [ Homepage: http://www.bertran.uni.cc/ORION ]
Why there are no updates on the current donation and add revenue status? helping out Joomla! users, "giving back" to the community...
Testing Joomla! 1.5 beta 2 SVN on http://bertran.uni.cc/j15b2

Terenzusum
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 189
Joined: Thu Aug 18, 2005 4:07 pm
Contact:

Re: How to use the patTemplate in joomla!

Post by Terenzusum » Wed Apr 11, 2007 9:53 pm

just wanted to ask

Why we need to keep obsolete pattemplate library if only 1 user needs it now?

and then 1.5 be ready for production (today no one can say when it comes out) no one will use obsolete system apart laziest ones

even masterchief who introduced pattemplate in joomla admits above trying to get rid of pattemplate
Poll [ Homepage: http://www.bertran.uni.cc/ORION ]
Why there are no updates on the current donation and add revenue status? helping out Joomla! users, "giving back" to the community...
Testing Joomla! 1.5 beta 2 SVN on http://bertran.uni.cc/j15b2

Terenzusum
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 189
Joined: Thu Aug 18, 2005 4:07 pm
Contact:

Re: How to use the patTemplate in joomla!

Post by Terenzusum » Wed Apr 11, 2007 10:00 pm

for all pattemplate lovers, I doubt there are much of them

I loved pattemplate also, but it get autdated because pattemplate developers abandoned it, and couldn't keep their promises

we need to admit it and remove this librarry

its time to change

dont waste your oportunity joomla 1.5 is in beta level dont forget it
Poll [ Homepage: http://www.bertran.uni.cc/ORION ]
Why there are no updates on the current donation and add revenue status? helping out Joomla! users, "giving back" to the community...
Testing Joomla! 1.5 beta 2 SVN on http://bertran.uni.cc/j15b2

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3763
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: How to use the patTemplate in joomla!

Post by Hackwar » Thu Apr 12, 2007 8:36 pm

We wont remove the library from 1.5, since its in there since Mambo 4.5.2.something and allready some, although very few, extensions are using it. It will be gone somewhere in the next versions. maybe 1.6, maybe 2.0. We will see.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

ziad
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Sun Nov 26, 2006 12:48 pm
Location: London

Re: How to use the patTemplate in joomla!

Post by ziad » Wed Apr 18, 2007 2:17 pm

Interesting thread this one...I lost track of it because I stopped getting email alerts, just came back to it today.

So in version 1.5 Joomla! will be moving to a MVC architecture, that sounds great. I do think that the way things are at the moment (app logic and view logic mixed up/PHP and HTML mixed up) is a big problem with Joomla! So MVC would be a big step in the right direction.

So any ideas what will be used for the view part? I looked through the API for v.1.5 and saw a JView class but I assume this will be used internally by Joomla! to render the view. Am I correct? I assume the view will be some sort of a templating engine like smarty rather than having to extend the JView class and putting your view code in there. Does anybody have any ideas as to what the view technology/tool will be?

Regards
Ziad

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3763
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: How to use the patTemplate in joomla!

Post by Hackwar » Wed Apr 18, 2007 2:26 pm

look into the current nightly builds about this.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4785
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: How to use the patTemplate in joomla!

Post by ianmac » Wed Apr 18, 2007 4:15 pm

ziad wrote: Interesting thread this one...I lost track of it because I stopped getting email alerts, just came back to it today.

So in version 1.5 Joomla! will be moving to a MVC architecture, that sounds great. I do think that the way things are at the moment (app logic and view logic mixed up/PHP and HTML mixed up) is a big problem with Joomla! So MVC would be a big step in the right direction.

So any ideas what will be used for the view part? I looked through the API for v.1.5 and saw a JView class but I assume this will be used internally by Joomla! to render the view. Am I correct? I assume the view will be some sort of a templating engine like smarty rather than having to extend the JView class and putting your view code in there. Does anybody have any ideas as to what the view technology/tool will be?

Regards
Ziad
each view extends the JView class.  Then in your JView class, you push your data into the template.  The extension of the JView class is just like the classes that used to be used in xxxx.html.php.  Inside the template itself, PHP is used rather than trying to create a wrapper around what is already there.  That way templates don't have to be parsed twice.

Ian

ziad
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Sun Nov 26, 2006 12:48 pm
Location: London

Re: How to use the patTemplate in joomla!

Post by ziad » Wed Apr 18, 2007 10:36 pm

Thanks for your post Ian. So the JView class will be extended to put the code that pushes the data into the template and then the template will do the actual presentation (HTML say). But what will this template be? If I've understood you correctly, you are saying that the template will be a PHP file that contains mainly HTML but has PHP embedded in it containing view logic (e.g. looping through a set of data, IFs etc).

I can see how that might work if you strictly limit yourself to view logic, but isnt that kinda going against the principle of MVC? I mean shouldnt the view be something that doesnt allow you to do PHP stuff (unless it is absolutely neccessary)?

As you suggested Hacwar, I should have a look at this stuff myself but unfortunately as much I would love to do that, I just will not get the time to do it, so if anyone has already looked at it and can provide some insight that is very much appreciated.

Thanks
Ziad

User avatar
masterchief
Joomla! Hero
Joomla! Hero
Posts: 2316
Joined: Fri Aug 12, 2005 2:45 am
Location: Brisbane, Australia
Contact:

Re: How to use the patTemplate in joomla!

Post by masterchief » Wed Apr 18, 2007 10:42 pm

Ziad, would you mind kicking this discussion off in it's own topic.  Thanks.
Andrew Eddie - Tweet @AndrewEddie
<><
http://eddify.me
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.

ziad
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Sun Nov 26, 2006 12:48 pm
Location: London

Re: How to use the patTemplate in joomla!

Post by ziad » Thu Apr 19, 2007 8:35 am


User avatar
Xscratch
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Wed Jun 21, 2006 9:41 am
Location: Monte Vederna (1300mt), Primiero, Trentino, Italy
Contact:

Re: How to use the patTemplate in joomla!

Post by Xscratch » Thu Jun 21, 2007 4:42 pm

Why the "Hello World" tutorials in the Joomla! Help Site are still explaining how to develop components using patTemplate if it is deprecated?
IMHO that is the first place a new extension-developer will look (me too)!  :(

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4785
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: How to use the patTemplate in joomla!

Post by ianmac » Thu Jun 21, 2007 4:55 pm

The help site has 1.0 developer resources.  patTemplate can be used in Joomla! 1.0.  In 1.5, it is deprecated.  Please visit dev.joomla.org for developer resources for programming Joomla! 1.5.

Ian


Locked

Return to “patTemplate”