eZ Community » Forums » Extensions » Modules: Fetching templates problems...
expandshrink

Modules: Fetching templates problems with 4.3

Modules: Fetching templates problems with 4.3

Thursday 26 August 2010 12:39:43 pm - 10 replies

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

Modified on Thursday 26 August 2010 12:46:23 pm by Daniel Perdomo Lorenzo

Thursday 26 August 2010 1:23:57 pm

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

Modified on Thursday 26 August 2010 1:25:27 pm by Ivo Luka─Ź

Thursday 26 August 2010 1:46:40 pm

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();

Thursday 26 August 2010 1:46:48 pm

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 ?>

Modified on Thursday 26 August 2010 1:55:18 pm by Daniel Perdomo Lorenzo

Thursday 26 August 2010 2:06:36 pm

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!!!

Thursday 26 August 2010 2:44:47 pm

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.

Thursday 26 August 2010 4:20:55 pm

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"

Thursday 26 August 2010 5:28:21 pm

Using your folder structure, the call should be:

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

Modified on Thursday 26 August 2010 5:30:30 pm by Peter Keung

Thursday 26 August 2010 5:46:21 pm

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');

Modified on Thursday 26 August 2010 5:47:33 pm by Daniel Perdomo Lorenzo

Friday 27 August 2010 12:17:26 am

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

Friday 27 August 2010 10: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. happy.gif Emoticon)))

Thanks all for help me!!!!!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from