Path

ez.no / ezpublish / documentation / customization / custom design / template variables set by ezpublish


Template variables set by ezPublish

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

This document is an explaination of some of the variables that can be
used in templates.

Both these variable are safe to use when view caching is on.

1 Pagelayout (or overrides)

The following can be used in pagelayout templates to display the values of these variables:

module_result <br />{$module_result|attribute(show,5)}

designkeys <br />{$DesignKeys:used|attribute(show,5)}

view_parameters <br />{$view_parameters|attribute(show)}

uri_string {$uri_string} <br />

requested_uri_string {$requested_uri_string} <br />

site <br />{$site|attribute(show)}

ezinfo <br /> {$ezinfo|attribute(show)}

1.1 $module_result

The attributes that are available may differ depending on view caching is on. Below the most safe ones to use.

view_parameters (array=Array)

   offset (integer=0)

path (array=Array)

   0 (array=Array)

       text (string=Root folder)

       url (string=/content/view/full/2)

       url_alias (string=)

       node_id (string=2)

   1 (array=Array)

       text (string=Products)

       url (boolean=)

       url_alias (boolean=)

       node_id (string=556)

title_path (array=Array)

   0 (array=Array)

       text (string=Products)

       url (boolean=)

       url_alias (boolean=)

section_id (string=1)

node_id (string=556)

navigation_part (string=ezcontentnavigationpart)

uri (string=/products)

1.1.1 $module_result.content

This attribute holds the content that the module called in the URL generated.

For instance when you run the module content/view/full/2 the module will fetch a template and set the result in module_result under the attribute content.

The template variable {$module_result.content} is usually found in pagelayout.tpl templates and holds the main page content.

1.1.2 $module_result.view_parameters

>offset integer
The view_parameters attribute is an array. I have only seen this
contain the "offset" element. This element is used for paged content.

1.1.3 $module_result.path

>0 array
>>text string 'Root folder'
>>url boolean false
>>url_alias boolean false
>>node_id string 2
This attribute is an array and provides information about the current location within the node tree. It has many uses, such as:

Element '0' should always be the root node, and the last element will be
the current node.

The attributes of each element are:

  • text - Name of the node
  • url - URL of the node or false if current node
  • url_alias - Nice URL of the node or false if current node
  • node_id - The node_id of the node

1.1.4 $module_result.title_path

Like the path array this attribute is also an array. I am not sure the purpose of this attribute and how it differs from the path attribute.

1.1.5 $module_result.section_id

What section does the current node belong to. Not set for some modules, such as search or login.

1.1.6 $module_result.node_id

The node_id of the current node. Not set for some modules.

1.1.7 $module_result.navigation_part

The navigation part assigned to the current node. Associated with the section the current node is assigned to.

1.1.8 $module_result.uri

The URI used to access this node.

1.2 $DesignKeys:used

This variable is set in all(?) modules, however the attributes that are available may differ.

section (string=1)

object (string=564)

node (string=556)

parent_node (string=2)

class (string=1)

view_offset (integer=0)

viewmode (string=full)

depth (string=2)

Fetching and displaying content will alter the value of this variable. So if you are getting strange values in the variable add debugging to check the value at the top of the template and at the bottom. You may need to store attribute values in other variables.

1.2.1 section

The section ID assigned to the current node.

1.2.2 object

The object ID of the object associated with the current node.

1.2.3 node

The Node ID of the current node

1.2.4 parent_node

The Node Id of the current node's parent.

1.2.5 class

The Class ID of the current node

1.2.6 view_offset

Same as $module_result.view_parameters['offset']

1.2.7 viewmode

The view mode used to display the current node.

1.2.8 depth

The depth of the current node with in the node tree. Should be equal to the number of elements in $module_result.path.

1.3 Get the current user $current_user

First you will need to fetch it

{let current_user=fetch('user','current_user') }

1.3.1 Which is the main group of the current logged in user

....

{let current_user=fetch('user','current_user') }

...

<p> I belong to the group with ID {$current_user.contentobject.main_parent_node_id}</p>

 

{/let}

2 Inside view templates for classes/objects

2.1 The base variable of "everything": $node

Here you basically have one variable to do it all

$node

Don't worry about view caching or not: when cached, the template isn't used anyway.

2.2 Object attributes

Now for fun, put {$node|attribute(show,3)} inside a template for an existing object (and not a production site of course). You will see plenty of nice stuff contained inside $node.

For example

$node.node_id

the ID of the node

$node.object

the content object which lives in this node

$node.sort_array

the default sorting method as specified in teh admin interface. You should use that in fetch() functions to get the default sort method (but you may have reasons to change that)

$node.data_map

an array of all the attributes associated with the object

$node.name

the name of the node (object)

Of particular importance is the data_map array, since the attributes contain the content that you want to display. How to to this is mostly simple, but some special data types have their own stuff:

Datatype

method to use

output

most attributes

$node.data_map..content

well, exactly what's in there

image

$node.data_map.content[image_size].full_path

the url of the image to use in tags. Replace image_size by small, medium, large, reference or your custom defined size (ezp3.2)

XML text field

$node.data_map..output.output_text

the xhtml converted xml content. Use this with mofifying operators (like the contributed glossary operator)

2.3 More fun stuff

2.3.1 Can the current user edit the current object?

You don't need to fetch the current user into an object for this

<form name="fullview" method="post" action={"content/action"|ezurl}>

{switch match=$node.object.can_edit}

{case match=1}

<input type="hidden" name="ContentObjectID" 

value="{$node.object.id}" />

<input class="button" type="submit" name="EditButton" 

value="{'Edit'|i18n('design/standard/node/view')}" />

{/case}

{case match=0}

{/case}

{/switch}

{/form}

2.3.2 Who is the one that modified the current version?

Use the contentobject_version_object!

{$node.contentobject_version_object.creator.name}

2.3.3 And when did he do that??

last modified: {$node.contentobject_version_object.modified|l10n(shortdatetime)}

2.3.4 Can I email the one that modified it?

Don't be afraid to dig a few levels deeper into $node :-)

<a 

href="mailto:{$node.contentobject_version_object.creator.<remove linebreak>

contentobject_attributes.2.content.email}">

Send Email</a>

Comments

Some other template variables

Some other template variables set by index.php are:

current_user
anonymous_user_id
access_type (usefull: access_type.name contains the name of the siteaccess)
...

If you want to have a full list, just search index.php for "$tpl->setVariable(".

data_map attribute

Thank you for the $parent.data_map.[day].data_int example!!!!

Without it, I would never figure this stuff out.

:)

pagelayout.tpl seems to have no effect

Hi,

Using 3.4.1, adding pagelayout.tpl to the design/mysite/templates doesn't appear to have any effect. I also tried adding it in design/mysite/override/templates with no success.

I noticed that in settings/siteaccess/mysite/site.ini.append.php there is the following:

[DesignSettings]
SiteDesign=mysite
AdditionalSiteDesignList[]=base

"base" is definitely being used. How do we override this and why is it even there?

Help!

Clarify the data_map stuff, please

Hi,

please extend the documentation on how to access the value of data through the datamap!
The little table does not help a newbie much, for example, it does NOT mention, that you need the attribute identifier behind the .data_map. part!
Print some example.
And add "date" and "datetime" datatypes, as .content does not work here, but has to be $node.data_map.[attribute identifier].data_int

Re: I am lost...Where's the documentation??

If you're new to eZ publish, I would strongly advise you to check out the following chapters (from the docs):

http://ez.no/ez_publish/documentation/ez_publish_basics

http://ez.no/ez_publish/documentation/building_an_ez_publish_site


Cheers!

Balazs

I am lost...Where's the documentation??

I have installed it and it works. But how can I customize it? I tried to add pictures and stuff and it does not take html coding. I signed in and tried to read, but it does not make sense to me. EZ???? if this is ez how it is if it was hard to do. Help!! where can I learn all this. I am sure it is cool once you learn it, but where???

How do i cahnge and add new layout /design

Hello,
I have installed the ezpublish-3[2].3-4 on my local.After installing it gave me two links http://localhost/ezpublish/index.php/corporate for user and
http://localhost/ezpublish/index.php/corporate_admin for admin it is working with the default layout. Now how do i change/ added the layout/design to ezpublish.i tried to add new layout as per the instaruction given on http://www.sitepoint.com/article/ez-publish-3-1-take-spin/3.But i am not able to add my site design on the list of active sitedesign.I Don't know where i did mistake.
Thanks
Ashok Naidu

Apache Crashing - More Info

I found that Apache's current thread dies when using the following syntax on a Windows setup:

{$node|attribute(show,3)}

I changed the 3 to a 4 and it still occurred which I found out to mean the number of levels down to drill: http://ez.no/developer/ez_publish...tion/tips_tricks/debugging_templates

Then I changed it to 2 and it output some very nice information. So I'm halfway to figuring out this strange issue. Anyone have any ideas?

Apache Crashing

Sorry - pointing to section 2.2 in this document.

Crashed Apache Every Time

Now for fun, put {$node|attribute(show,3)} inside a template for an existing object (and not a production site of course).

I'm using 3.2 on a Windows machine with the install package and everytime I try access an object with that line of code in it's template Apache crashes and Windows alerts me. Anyone else having that issue? Pretty strange.

What do you mean no programming?

I look at the text throughout this documentation and see little if any explanation on how to modify the system to get it to look how you want it to look. I tried to remove it after spending a day trying to figure out template variables. What is that if it's not programming? give me ordinary PHP any day! I figured it might use TPL files with a header and footer which you simply go in modify to suit and away you go but it appears there are hundreds of files to modify. Is there anywhere which explains step by step how to begin changing the system to suit your own needs?

Contents

Customization

Access control
eZ publish API Documentation
Content structure
Custom design
    User specified parameters
    Template variables set by ezPublish
    Introduction
    Variables, arrays and objects
    Node
    Database connectivity
    Sections
    File placement
    Override templates
    node_view_gui
    Pagination
    Caching
    Stylesheets
    Pagelayout
    Printable pages
    Examples
Components
Tips & Tricks
Troubleshooting


Created

19/08/2003
4:28:07 am
by Paul Borgermans

Last updated

29/09/2004
1:58:20 am
by Björn Dieding@xrow.de

Authors

Paul Borgermans
Björn Dieding@xrow.de



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.