This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Setup & design » How to use custom template?
expandshrink

How to use custom template?

How to use custom template?

Wednesday 09 June 2010 6:11:20 pm - 5 replies

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

http://ez.no/doc/ez_publish/techn...lates/template_basics/node_templates

http://ez.no/doc/ez_publish/techn...mplates/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 happy.gif Emoticon

Modified on Wednesday 09 June 2010 6:12:03 pm by Steven Stieng

Wednesday 09 June 2010 6:56:22 pm

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?

Wednesday 09 June 2010 8:24:54 pm

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.

Thursday 10 June 2010 10: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 happy.gif Emoticon
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.

 

Modified on Thursday 10 June 2010 11:04:23 am by Steven Stieng

Thursday 10 June 2010 10: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

 

Modified on Thursday 10 June 2010 11:09:27 am by Steven Stieng

Thursday 10 June 2010 12:06:36 pm

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.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from