Path

exponential.earth / exponential / documentation / building an ez publish site / the welcome page / creating and using a custom template


Creating and using a custom template

These documentation pages are no longer maintained. Please visit the new documentation site.

Because we are unsatisfied with the way our welcome page is displayed, we will create a custom template. We can instruct eZ publish to use a desired template each time a specific node is accessed.

Our welcome page contains information that should not present in the welcome text. The date, the creator of the article, "Tip a friend", and "Download PDF version of this page" should be hidden. Therefore we override the default template, display the introduction text, body text, and the image.

The following guide should take you through the necessary steps.

  1. Bring up the administration interface.
  2. Click on the "Design" tab.
  3. Click on "Templates" (in the menu on the left hand side).
    A list of template files will appear.
  4. Locate a file called "/node/view/full.tpl" and click on it.
  5. On the next page, simply click "New override".
  6. Type in "full_view_welcome" into the template name field.
  7. Make sure the dropdown box "Section" is set to "All sections" and "Class" is set to "All classes".
  8. Type in the identification number of the welcome-page node.
  9. Make sure that "Empty" is chosen in the "Base template on" section.
  10. Press "OK" button.

eZ publish will then generate a custom template that will be used instead of the standard template every time the specified node is accessed. The newly generated template file will be put in the "design/tscm/override/templates/" directory. Edit the newly generated file. You can either use the administration interface, by clicking on the edit icon for the desired template file (if the 'could not open file' warning popups up, you can safely ignore it), or use your favourite text editor. Put the following lines into the file:

<div class="pagetitle">

   {attribute_view_gui attribute=$node.object.data_map.title}

</div>

<div class="imageright">

   {attribute_view_gui attribute=$node.object.data_map.image}

</div>

{attribute_view_gui attribute=$node.object.data_map.intro}

{attribute_view_gui attribute=$node.object.data_map.body}

This template code will simply extract the contents of the welcome object and display it in a nice way.

Raise the priority of this template to 1, and clear the override caches. The welcome page hides: the date, the creator of the article, "Tip a friend", and "Download PDF version of this page".

Comments

unable to create an override in 3.9

Hi all. Using version 3.9 and when I go through the process of making the override template and hit ok, it takes me back to the the screen to create a new template and shows that there are no overrides. I try clearing the cach but nothing. anyone else getting this? any solution that I am not seeing? thanks for any advice.

Only link to image shown instead of image itself

Hi all

This code is not showing the image:



{attribute_view_gui attribute=$node.object.data_map.image}



Following template is automatically taken:
design/standard/templates/content/view/text_linked.tpl

Any hints?

eZ Publish version 3.8.3, Apache 1.3, PHP 4.4.3RC3-dev, WinXP Pro.

Thanks,
Roger

Image in 3.5.2

I could'nt display image image in both 3.5.1 and 3.5.2 .
Could anyone solve this problem,

I also used this
{attribute_view_gui attribute=$node.object.data_map.title}

and did'nt get title and then added data_text

{attribute_view_gui attribute=$node.object.data_map.title.data_text}

to get the title , Same way for image Iam using

{attribute_view_gui attribute=$node.object.data_map.resource_thumbnail}

but not getting the image.Is there any other combination to add at last inorder to get the image displayed.Please help me ASAP in this case.


Image doesn't display at all?

In 3.7.0.rc1. I'll probably trace it down later. I'm guessing some syntax change happened to define the image attribute. (The sapce between the appropriate <div>'s is empty).

Custom templates broken in 3.5.1 - fixed in 3.5.2

Custom templates seemed to be broken (I did not achieve to use the full_view_welcome) with 3.5.1. Everything is working fine with today's update (3.5.2). Thanks eZ for the fix !

Change siteaccess to tscm to make the template work

After step 2 I had to change "Siteacces" from admin to tscm (remember to click "set") in order for the page to display correct. If not the template is used for admin access. Remember to raise the priority from 21 to 1. I'm not sure if it should be 19, 10, 7 or 1 :-)

Welcome Page

The following code does not accomplish what it is supposed to.
In full_view_welcome.tpl:

<div class="pagetitle">
{attribute_view_gui attribute=$node.object.data_map.title}
</div>
<div class="imageright">
{attribute_view_gui attribute=$node.object.data_map.image}
</div>
{attribute_view_gui attribute=$node.object.data_map.intro}

{attribute_view_gui attribute=$node.object.data_map.body}

Image floated right?

To get it to work I had to remove '<div class="imageright">' and it's closing '</div>'. Otherwise I got embedded '<div class="imageright">'s which caused the image to float to the right, but the text to appear below it. At least this was the case with Firefox 1.0 and eZ Publish 3.5.0.

Image in the right position of the text

The image is right-aligned but the text is below it.
To have the image in the right side of the text I put the closing tag </div> at the last line.

Finally!

After 5 or 6 attempts, I finally made it through 'Creating and Using a Custom Template.' I had to repeat one of the shell commands that was used during installation from the 'root' directory:

chmod -R a+rwx design

This allowed creation of an empty file without the 'permission denied' error message. I was not able to edit the empty file from within the administrative interface, however.

I've been following a printed version of the building.pdf file as well as the online version (allows for copy/paste). Apparently these are different, the online version being more up-to-date (but not current with version 3.4.4).

At this point, I wouldn't mind an explanation of the templates under /node/view/full and how the priorities work. Also explain the formatting commands in full_view_welcome. The way the commands were explained in the 'Hello world!' example was excellent. This style should be followed throughout the rest of the documentation (now that I've successfully set up my welcome page, I can look at the rest of the documentation!)

Thanks for the great work on 'Ez publish'!!!

Contents

Building an eZ publish site

Prerequisits
Situation
Creating the TSCM site
Testing the interfaces
Setting up the main layout
Creating sections
The welcome page
    Adding the contents of the welcome page
    Setting the default page
    Creating and using a custom template
The news page
The members page
The guestbook
The links page


Created

21/10/2003
3:42:00 pm
by Balazs Halasy

Last updated

23/11/2004
2:07:19 pm
by Raymond Bosman

Authors

Balazs Halasy
Raymond Bosman



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.