eZ Community » Forums » Developer » Module .tpl issue
expandshrink

Module .tpl issue

Module .tpl issue

Friday 01 October 2010 10:52:30 am - 8 replies

Hello,

I'm having an issue creating new module. I follow step of the tutorial and I'm having trouble loading the .tpl file. I create the extension folder, corresponding php wich works. It display test echo message, but when I try to bind it with .tpl file, it says something like:

No template could be loaded for "modul1/list.tpl" using resource "design"

This is inside my extension, the path is: [http root]newez\extension\jacextension\design\standard\templates\modul1\list.tpl

But when I put this tpl file in the base design, it works, so it's in the path [http root]\newez\design\base\templates\modul1\list.tpl

What am I doing wrong? - How can I place this template in my extension, so this file is used, not the one I put in base design?

Friday 01 October 2010 12:19:54 pm

Hi Ivan,

- When you create newmodulename in your newextension here are examples how the path ways looks like:

For newmodulename:

extension/newextension/modules/newmodulename/list.php

For list.tpl path :

 extension/newextension/design/newextension/templates/modulname/list.tpl

Then when you call template in list.php do it like this:

 $template = "design:newmodulename/list.tpl";

Modified on Friday 01 October 2010 6:44:57 pm by Mario Ivancic

Friday 01 October 2010 1:44:39 pm

Just replying to have 3 Croats in one thread blunk.gif Emoticon

Friday 01 October 2010 2:17:39 pm

For list.tpl path :

 extension/fat/design/fat/templates/modulname/list.tpl

Hi,

If you want to have your design on your front end and your back end, you have to create your template in a design called standard.

Modified on Friday 01 October 2010 2:18:03 pm by Frédéric DAVID

Friday 01 October 2010 5:16:34 pm

Just to check... have you cleared the cache?

Sunday 03 October 2010 7:20:22 pm

Hi Ivan,

- When you create newmodulename in your newextension here are examples how the path ways looks like:

For newmodulename:

extension/newextension/modules/newmodulename/list.php

For list.tpl path :

 extension/newextension/design/newextension/templates/modulname/list.tpl

Then when you call template in list.php do it like this:

 $template = "design:newmodulename/list.tpl";

Hello, thank you for your reply.

I've done exacley that and nothing. I even named my folder as standard design. It just doesn't take the .tpl file from within the module but from the one in root/ezpublish/design..

Am I missing something? (version is 4.x)

Sunday 03 October 2010 7:52:38 pm

Have you setup your extension to serve designs/templates?

extension/newextension/settings/site.ini.append.php

[TemplateSettings]
ExtensionAutoloadPath[]=newextension

Then put your template in

extension/newextension/design/standard/templates/somefolder/list.tpl

and you can refer to it in your module-php-code via

$tpl = templateInit();
$tpl->setVariable('foo', $foo); 
$templateResult = $tpl->fetch( 'design:somefolder/list.tpl' ); 
 
$Result = array();
$Result['content'] = $templateResult;

That should it be.

Chris.

Modified on Sunday 03 October 2010 8:06:50 pm by Christian Rößler

Sunday 03 October 2010 8:05:34 pm

Addition Info: If you want to provide a new DESIGN (besides standard) and in this design provide templates, do this:

Create the following directory structure:

extension/newextension/design/foo/templates
extension/newextension/design/foo/stylesheets
extension/newextension/design/foo/javascript
extension/newextension/design/foo/images

Put your design ressources (js, css, img) into the proper directories.

Put your Template into

extension/newextension/design/foo/templates/somefolder/list.tpl

And change/edit/add the following ini files:

extension/newextension/settings/site.ini.append.php
[TemplateSettings]
ExtensionAutoloadPath[]=newextension

and

extension/newextension/settings/design.ini.append.php
[ExtensionSettings]
DesignExtensions[]=newextension

At last, make eZPublish do recognize the design "foo" by doing the following in your override site.ini or your siteaccess site.ini...

Override site.ini:

settings/override/site.ini.append.php
[ExtensionSettings]
ActiveExtensions[]=newextension
 
[DesignSettings]
SiteDesign=foo

Or when using the siteaccess site.ini:

settings/siteaccess/<NAME OF SITEACCESS HERE>/site.ini.append.php
[ExtensionSettings]
ActiveAccessExtensions[]=newextension
 
[DesignSettings]
SiteDesign=foo

That should do the trick

Modified on Sunday 03 October 2010 8:08:30 pm by Christian Rößler

Monday 04 October 2010 1:27:19 pm

Thank you for your reply, it works now. Maybe something in my ini was not right. But I also formated them in UTF-8 format, and reloaded autogenerate arrays...Maybe it was that. But I also changed ini files, so thank you. It works and that's what matters happy.gif Emoticon

There is still one more question. How can I use this module as a class? - So I can let my users to insert this module. It's not a very elegant solution to have just a link.

How is this normaly done in ezPublish?

Cheers

Modified on Monday 04 October 2010 1:31:58 pm by Ivan Švogor

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from