Forums / Setup & design / override.ini or smart file placement ?

override.ini or smart file placement ?

Author Message

*- pike

Thursday 11 October 2007 2:06:40 am

Hi

there seems to be two ways to 'override' a template in a certain design:

- add a line to override.ini, where you specify the location of an alternate
template based on class or nodeid
- put the alternate template in a place where ezpublish expects it, like
../design/yourdesign/templates/node/view/line/article.tpl

- is that correct ?

- the preferred mechanism seems to be override.ini. why ?

- what is the order in which ezp checks for overrides ?
I assume override.ini overrides everything, so it is checked first ?

- which is more efficient: adding 1000 lines to override.ini (which
makes it long to parse/execute at each request) or add 1000 templates
on the right place (which needs a few system calls before ezp
finds out where the overriding template is located ) ?

currently, we use a huge override.ini, and performance is bad; i want to know if we could improve performance by decreasing the size of that file .. or i want to know how much performance will suffer if i do that anyway :-)

thanks!
*-pike

---------------
The class eZContentObjectTreeNode does.

Nabil Alimi

Thursday 11 October 2007 2:23:01 am

Interesting question. I do not have the answer but there's one thing you should know :

Override files aren't parsed every time we need them but only the first access of the site. Then, they are compiled in a simple php file.

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Laurent BOURREL

Thursday 11 October 2007 2:56:47 am

Hi,

To my mind, these 2 ways answer 2 different questions.

- Placing the tpl directly in the design is a generalization : you replace the original tpl by this one without considering the class of the object, of the attribute, the section, etc.

- Using the .ini file is a specialization : you override the template using conditions (class name, attribute name, section, ... it depends the tpl you want to override :
http://ez.no/doc/ez_publish/technical_manual/3_9/reference/template_override_conditions

hth...

*- pike

Thursday 11 October 2007 4:27:37 am

Hi

thanks for both your messages.

Laurent, ofcourse you are right, they are different mechanisms with different usages. I have a override.ini with a lot of ClassID matches, which I could also simply do with smart template placement; but there are other cases in which they are not interchangeable.

Nabil, indeed the override.ini file get's 'cached' into a php file (in var/xxx/cache/override). Not sure if it is a 'simple' file though, it is a large php array (105k in my case), which contains a lot of php conditionals that have to be eval()'ed. This has to happen at every request, so it is still a big overhead in performance, and ~100k of memory, I guess.

So, what would be the most efficient ?

thanks!
*-pike

---------------
The class eZContentObjectTreeNode does.

Damien Pobel

Thursday 11 October 2007 5:08:09 am

Hi *-pike,

I think you won't really improve performances of your site by decreasing the size of the override.ini and its cache.
Instead, you should have a look at articles [1] and forum topics [2] about performances problems. There's simple things to do like installing an opcode cache (like eAccelerator or APC) and more difficult like templates optimizations.

[1] http://ez.no/developer/articles/ez_publish_performance_optimization_part_3_of_3_practical_cache_and_template_solutions
[2] http://ez.no/developer/forum/general/ez_publish_performance_optimisation_faq

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

*- pike

Thursday 11 October 2007 8:50:09 am

Hi Damian

that second link is extremely usefull !!

for the first link, we've looked at / tried / tested / measured most of the options. and we did have some improvement. nevertheless, performance is bad again and dropping as we grow.

my remaining question would be: how much would the performance drop if, instead of using override.ini for matching templates by Class ID, I just put the templates on the right place, like in /design/mydesign/templates/node/view/line/article.tpl ?

because I actually prefer the second method :-)
unless it slows everything down ofcourse.

thanks!
*-pike

---------------
The class eZContentObjectTreeNode does.

*- pike

Tuesday 12 February 2008 12:10:25 pm

just for future readers:

I did have something wrong here. ezpublish doesnt 'just expect' to find a line view for a article in

/design/mydesign/templates/node/view/line/article.tpl

If you explicitly request a

{node_view_gui view="line"}

, ezpublish will look for a template somewhere called node/view/line.tpl. amongst others, it will look in

/design/mydesign/templates/node/view/line.tpl

if there happens to be an entry in override.ini for node/view/line.tpl, for class 'article', it will ofcourse follow whatever that entry says. beware, the base design already gives such overrides.

To limit your override.ini, you can ofcourse put a template at

/design/mydesign/templates/node/view/line.tpl

and add a switch in there that does something special for class "article". but such a switch is similar to what appears in override.ini after it is compiled (however, it won't be parsed at each request - so i think its more efficient).

If you (like me) are then tempted to write line templates that look like

{switch $class}
  {case $cx}{include uri="$ux"}{/case}
  {case $cy}{include uri="$uy"}{/case}
{/switch}

bear in mind, that includes are again less efficient..

*-pike

---------------
The class eZContentObjectTreeNode does.