Forums / Developer / template and developer tips

template and developer tips

Author Message

Samuel Sauder

Tuesday 19 September 2006 7:18:07 am

http://www.wormus.com/aaron/stories/2006/09/19/ezpt-templating-best-practices.html
After reading this I figured I would add some more:
1. if possible avoid sections as they require an additional role/policy configuration.
2. Match[url_alias]=folder/subfolder/node is your friend and it took me awhile to find it in the overrides options. I prefer it instead of matching on node
3. setup a developer siteaccess that has template caching turned off. It is much quicker in the long run versus waiting for the cache reset for every little change.
4. install the Dynamic debug extension
http://ez.no/community/contribs/hacks/dynamic_debug

Aaron Wormus

Tuesday 19 September 2006 7:59:30 am

Thanks, that Dynamic debug extension looks good.

1. Does the role/policy configuration cause any sort of performance slowdown?
2. I've found that without caching turned on the backend is too slow to do anything useful in (other than just editing the ini and tpl files is there any way to get around the speed issue?

Xavier Dutoit

Friday 22 September 2006 7:18:09 am

Hi,

I tend to find more efficient keeping the template caching, but to only disable the template compiling.

X+

http://www.sydesy.com

Xavier Dutoit

Friday 22 September 2006 7:28:55 am

Me again,

About Aaron naming convention, I prefer using folders than what he wrote (if I understood properly):

override/templates/<class>/<view>.tpl

So that's easier when you create a new class (that is often a copy of an existing one): you just copy the directory.

If I have several full views (override based on sections or node id), I tend to give them their functionnal name (it doesn't matter that it is node 42 and I prefer guide/itchhiker_full.tpl ;)

Otherwise, and for those of us that have to develop on the road (ie on a laptop with the client and the server on the same machine), and to keep as much memory free as possible, you can safely lower the number of apache process spawn (no need to have 10 processing swallowing you memory when you'll be the only one that's going to access the server anyway).

X+

P.S. On that scenario, I tend to prefer using lighttpd than apache, but that might be purely subjective.

http://www.sydesy.com

Samuel Sauder

Friday 22 September 2006 7:40:43 am

@X: I'll have to try that out. Thanks for the tip about disable compile instead!

@Aaron: 1. more just being lazy :) In most cases sections are not required because of the power of layering in overrides. In your example

Use Sections: When you want to change the look of a section of your site (ie: I want all the articles in my knowledgebase to have a blue headline) create a section for knowledgebase and then create an override for the class within the section.

You may not need a section. Overriding on class ( Match[class] ) and subtree ( Match[url_alias] ) will suffice.
See: http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_override_conditions#comment6200

Samuel Sauder

Tuesday 03 October 2006 7:18:06 am

Here's another reference:
http://pubsvn.ez.no/wiki/en/ez/debugging
http://pubsvn.ez.no/wiki/en/ez/developers

Samuel Sauder

Monday 09 October 2006 12:34:05 pm

Another important item on section behavior (advanced). It appears that for the /user/login and edit node views, the pagelayout chosen is smarter so that it doesn't use the default site layout but rather the layout chosen by the section. (I can't find any documentation for this)

The problem I was running into with matching by url_alias, it would always use the default site layout without any option I could think of to override it.

Or is there another way?

Sébastien Antoniotti

Wednesday 17 January 2007 10:39:26 am

Hi,

I "wake up" this topic to ask you about templates path :

I have made a custom class (named "artiste"), and I just want to define templates (.tpl) by using correct folders name, so I have tried this : override/templates/<class>/<view>.tpl (given by Xavier) but it doesn't works...

I have made this path : design/mydesign/override/templates/artiste/line.tpl, but since I cleared the cache many times, when I display an artiste node, the default line.tpl template is used...

thanks in advance !

eZ Publish Freelance
web : http://www.webaxis.fr

Xavier Dutoit

Thursday 18 January 2007 9:36:08 am

And what's the relevant part in your override.append.ini file ?

You don't have to be sorry of being french, it could happend even to the best of us ;)

X+

http://www.sydesy.com

Sébastien Antoniotti

Thursday 18 January 2007 9:56:41 am

Hi,

There is not relevant part in my override.ini because I want to define templates for my custom classes without the override.ini, but by naming templates subfolders and .tpl correctly.

Is it possible ?

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Thursday 18 January 2007 10:06:27 am

I think this was possible a long time ago, am I right about that? But that kind of system isn't used anymore.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Thursday 18 January 2007 10:29:13 am

Ok, so usually you systematically write a rule in the override.ini for each view of each custom class that you create ?

eZ Publish Freelance
web : http://www.webaxis.fr

Paul Borgermans

Thursday 18 January 2007 1:07:35 pm

That's basically it yes. Only "general" templates can be overriden like that.

You could use a wrapper template that looks up each template for each class and each view. But that may slow down things also I think (not measured though)

hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Sébastien Antoniotti

Thursday 18 January 2007 2:00:40 pm

ok, thanks to all for your help !

eZ Publish Freelance
web : http://www.webaxis.fr

eZ debug

Timing: Jan 18 2025 11:10:40
Script start
Timing: Jan 18 2025 11:10:40
Module start 'content'
Timing: Jan 18 2025 11:10:41
Module end 'content'
Timing: Jan 18 2025 11:10:41
Script end

Main resources:

Total runtime1.1464 sec
Peak memory usage4,096.0000 KB
Database Queries235

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0097 587.7109180.8359
Module start 'content' 0.00970.9366 768.5469832.1250
Module end 'content' 0.94640.1999 1,600.6719357.3125
Script end 1.1463  1,957.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.4074210.0002
Check MTime0.00140.1249210.0001
Mysql Total
Database connection0.00090.082510.0009
Mysqli_queries1.033690.16032350.0044
Looping result0.00290.24972330.0000
Template Total1.107596.620.5538
Template load0.00180.159220.0009
Template processing1.105796.451020.5529
Template load and register function0.00020.016710.0002
states
state_id_array0.00110.091810.0011
state_identifier_array0.00160.140520.0008
Override
Cache load0.00170.1448750.0000
Sytem overhead
Fetch class attribute can translate value0.00140.119170.0002
Fetch class attribute name0.00140.1238180.0001
XML
Image XML parsing0.00240.211570.0003
class_abstraction
Instantiating content class attribute0.00000.0034230.0000
General
dbfile0.00390.3382460.0001
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
14content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 48
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs