Forums / Setup & design / How to use custom template?

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.

eZ debug

Timing: Jan 18 2025 00:08:14
Script start
Timing: Jan 18 2025 00:08:14
Module start 'content'
Timing: Jan 18 2025 00:08:15
Module end 'content'
Timing: Jan 18 2025 00:08:15
Script end

Main resources:

Total runtime1.0558 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.8438180.8359
Module start 'content' 0.00500.9519 769.6797616.6172
Module end 'content' 0.95690.0988 1,386.2969341.3750
Script end 1.0557  1,727.6719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.3378210.0002
Check MTime0.00140.1313210.0001
Mysql Total
Database connection0.00070.066610.0007
Mysqli_queries0.980292.83922030.0048
Looping result0.00160.15112010.0000
Template Total1.028697.420.5143
Template load0.00190.182320.0010
Template processing1.026697.239020.5133
Template load and register function0.00020.018910.0002
states
state_id_array0.00200.185710.0020
state_identifier_array0.00180.171320.0009
Override
Cache load0.00180.1697980.0000
Sytem overhead
Fetch class attribute can translate value0.00100.096030.0003
Fetch class attribute name0.00090.081570.0001
XML
Image XML parsing0.00080.078830.0003
class_abstraction
Instantiating content class attribute0.00000.001170.0000
General
dbfile0.00170.1592280.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
22content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
23content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 76
 Number of unique templates used: 9

Time used to render debug report: 0.0002 secs