Module .tpl issue

Author Message

Ivan Švogor

Friday 01 October 2010 1:52:30 am

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?

Mario Ivancic

Friday 01 October 2010 3:19:54 am

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";

--
http://www.escapestudio.net
http://twitter.com/MarioIvancic

Ivo Lukac

Friday 01 October 2010 4:44:39 am

Just replying to have 3 Croats in one thread ;)

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

Frédéric DAVID

Friday 01 October 2010 5:17:39 am

"

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.

Blog : http://www.frefred.fr/blog/ez-publish
feZ Meta Data : http://projects.ez.no/fezmetadata

Quoc Huy Nguyen Dinh

Friday 01 October 2010 8:16:34 am

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

Ivan Švogor

Sunday 03 October 2010 10:20:22 am

"

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)

Christian Rößler

Sunday 03 October 2010 10:52:38 am

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.

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

Christian Rößler

Sunday 03 October 2010 11:05:34 am

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

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

Ivan Švogor

Monday 04 October 2010 4:27:19 am

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 :)

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

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