Modules: Fetching templates problems with 4.3

Author Message

Daniel Perdomo Lorenzo

Thursday 26 August 2010 3:39:43 am

Hi all, I'm trying to do a simple extension. The extension contains a module, which fetches a template to put it into the module result's 'content' property. The fetch looks like this:

$tpl=eZTemplate::instance();
$Result ['content'] = $tpl->fetch ('design:jacextension/plan.tpl');

The template resides in the directory /extension/jacextension/design/jacextension/templates/plan/plan.tpl

The extension is set as a design extension:

<?php /* #?ini charset="utf-8"? # transmit to eZ, to search for designs in jacextension [ExtensionSettings] DesignExtensions[]=jacextension */ ?><?php /* #?ini charset="utf-8"? # transmit to eZ, to search for designs in jacextension [ExtensionSettings] DesignExtensions[]=jacextension */ ?>

I clear all cache too, but the debug output is always the same.

The debug output is:

No template could be loaded for "jacextension/plan.tpl" using resource "design"

Has anyone an additional idea where the error might be or how to debug/resolve it?

Kind regards,
Daniel Perdomo

Ivo Lukac

Thursday 26 August 2010 4:23:57 am

Hm, your path to template is wrong. Try this:

$Result['content'] = $tpl->fetch('design:plan/plan.tpl');

if you added jacextension in your design.ini

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

André R.

Thursday 26 August 2010 4:46:40 am

And it should be (for eZ Publish 4.3+ only):

$tpl = eZTemplate::factory();

Or using old syntax (so it works on older eZ Publish versions also):

require_once( 'kernel/common/template.php' );
$tpl =templateInit();

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Daniel Perdomo Lorenzo

Thursday 26 August 2010 4:46:48 am

thanks, i change the directory of the template:

extension/jacextension/design/jacextension/templates/jacextension/plan.tpl and i put the same fecth but still fail. i add jacextension in my design.ini.append.php and I have a module called jacextension with a view called plan.

/jacextension/setting/design.ini.append.php

<?php /* #?ini charset="utf-8"? # transmit to eZ, to search for designs in jacextension
[ExtensionSettings] DesignExtensions[]=jacextension ?>

Daniel Perdomo Lorenzo

Thursday 26 August 2010 5:06:36 am

Now i changed to eZTemplate::factory() but still fails :S . I tried a lost of directory but all of them fails:

extension/jacextension/design/templates/jacextension/plan.tpl

extension/jacextension/design/jacextension/templates/jacextension/plan.tpl

extension/jacextension/design/jacextension/templates/plan/plan.tpl

the url: http://localhost/pfc/index.php/jacextension/plan/ the default siteaccess is esl(Website Interface)

thanks a lot!!!

Bertrand Dunogier

Thursday 26 August 2010 5:44:47 am

I don't get it... does it work or not ?

The template string you're looking for is plan/plan.tpl. You might wanna consider moving your extension templates to a subfolder so that they can't conflict, like /extension/jacextension/design/standard/templates/jacextension/plan/plan.tpl.

Note that the string above uses the standard design as opposed to your custom jacextension one. This is on purpose, as it will make the extension portable to any eZ Publish.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Daniel Perdomo Lorenzo

Thursday 26 August 2010 7:20:55 am

thanks Bertrand but when i move the plan.tpl to subfolder

/extension/jacextension/design/standard/templates/jacextension/plan/plan.tpl and look for 'plan/plan.tpl'

( $tpl->fetch('plan/plan.tpl') )

don't work again.

with $tpl->fetch('jacextension/plan/plan.tpl') dont work too. The debug output is:

Notice: Aug 26 2010 14:20:33
eZTemplate: Loading template "plan/plan.tpl" with resource "design"
Warning: eZTemplate Aug 26 2010 14:20:33
No template could be loaded for "plan/plan.tpl" using resource "design"

Peter Keung

Thursday 26 August 2010 8:28:21 am

Using your folder structure, the call should be:

$tpl->fetch( 'design:jacextension/plan/plan.tpl' );

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

Daniel Perdomo Lorenzo

Thursday 26 August 2010 8:46:21 am

Thanks for reply, but this call don't work too with the structure /extension/jacextension/design/standard/templates/jacextension/plan/plan.tpl . I don't know why it doesn't work i desperate for this.

$tpl->fetch('design:jacextension/plan/plan.tpl');

André R.

Thursday 26 August 2010 3:17:26 pm

The last try looks correct, is the extension activated, is it configured to be an DesignExtension, did you clear cache (specifically template override cache)?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Daniel Perdomo Lorenzo

Friday 27 August 2010 1:01:40 am

I found the problem. it was that the charset in design.append.ini.php was set to iso-8859-1 and I needed utf-8. :))))

Thanks all for help me!!!!!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.