How to use custom template?

Author Message

Steven Stieng

Wednesday 09 June 2010 9:11:20 am

I'm trying to create a custom template. I've read the following pages:

http://ez.no/doc/ez_publish/technical_manual/4_x/templates/template_basics/node_templates

http://ez.no/doc/ez_publish/technical_manual/4_x/templates/the_template_override_system

But still can't figure out how my new template / class can be associated to the template file.

I've created a class called Page Article (page_article).
I've created a file called page_article.tpl and placed this in override/templates/full/.
I've created a override.ini.append.php and placed this in extension/ezwebin/settings/

In  override.ini.append.php I've put the following:
[page_article]
Source=node/view/full.tpl
MatchFile=page_article.tpl
Subdir=override/templates/full
Match[section]=1
Match[class]=2

What am I doing wrong?

 I'm a big fan of examples. That helps a lot :)

Steven Stieng

Wednesday 09 June 2010 9:56:22 am

UPDATE

I changed the INI file to this:

[page_article]
Source=node/view/full.tpl
MatchFile=page_article.tpl
Subdir=templates

And by moving my article_page.tpl to override/templates/ folder, the template is shown.
But my debug output still gives me some errors like:

Error: eZTemplate @ extension/ezwebin/design/ezwebin/override/templates/page_article.tpl:12[12]
Cannot retrieve attribute of a string

Error: eZTemplate @ extension/ezwebin/design/ezwebin/override/templates/page_article.tpl:19[8] Jun 09 2010 18:50:49
Cannot retrieve attribute of a string

The code in page_article.tpl is identical to the code in article.tpl

What could cause these errors?

André R.

Wednesday 09 June 2010 11:24:54 am

That highly depends on what you have on line 12 and 19 in that template (So yes, always post the lines of code you have issues with so people can help you, what code is on which line changes from version to version, so always post the line in question and a few lines above and bellow if it seems to be several lines involved in what ever happens on the lines something breaks).

Looked in full/article.tpl in webin, but there are no tpl code on line 12 so guess you made some changes. Additionally, if your class is different then article class, that probably explains it as well.

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

Steven Stieng

Thursday 10 June 2010 1:50:16 am

Sorry about that. I thought it might have something to do with some configuration. There is a lot of that in here :)
Yes, I have done a few changes. This is my code and starts at line 8:

{if $node.data_map.image_large.has_content}
    <img id="articleImageLarge" class="floatLeft" src={$node.data_map.image_large.content["original"].full_path|ezroot} alt="" />
{elseif $node.data_map.image.has_content}
    <img id="articleImage" class="floatLeft" src={$node.data_map.image.content["original"].full_path|ezroot} alt="" />
 {/if}

I'm using exact same code for article.tpl and it works fine.

Another question: Do I always have to override some template when I create a new tempalte_name.tpl file?

PS. Doing a {$node.data_map.image|attribute(show, 1)} gives me a lot of info.
So accessing the attribute is not the problem.

 

Steven Stieng

Thursday 10 June 2010 1:59:57 am

Ok, I've done some more research.

This code works and outputs the intro text:

{attribute_view_gui attribute=$node.data_map.intro}

But using this code gives me an error: 

{if $node.data_map.intro.content.is_empty|not}
    <div class="articleIntro">
      {attribute_view_gui attribute=$node.data_map.intro}
    </div>
{/if}
 

The error  is on the first line {if $node.data_map.intro.content.is_empty|not}.
Error message:

Cannot retrieve attribute of a string

 

Steven Stieng

Thursday 10 June 2010 3:06:36 am

Ok, new information.

For this template, the following code is wrong:
{if $node.data_map.intro.content.is_empty|not}

This code works:
{if $node.data_map.intro.has_content}

And for some reason, the test for the images works too, even though I haven't done anything.

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