ez.no / ezpublish / documentation / customization / custom design / 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.
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)}
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)
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.
>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.
>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:
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.
What section does the current node belong to. Not set for some modules, such as search or login.
The node_id of the current node. Not set for some modules.
The navigation part assigned to the current node. Associated with the section the current node is assigned to.
The URI used to access this node.
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. |
The section ID assigned to the current node.
The object ID of the object associated with the current node.
The Node ID of the current node
The Node Id of the current node's parent.
The Class ID of the current node
Same as $module_result.view_parameters['offset']
The view mode used to display the current node.
The depth of the current node with in the node tree. Should be equal to the number of elements in $module_result.path.
First you will need to fetch it
{let current_user=fetch('user','current_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}
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.
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) |
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}
Use the contentobject_version_object!
{$node.contentobject_version_object.creator.name}
last modified: {$node.contentobject_version_object.modified|l10n(shortdatetime)}
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
Kristof Coomans
Thursday 10 February 2005 9:03:12 am
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
Betsy Gamrat
Friday 12 November 2004 6:13:16 am
Without it, I would never figure this stuff out.
:)
pagelayout.tpl seems to have no effect
Gustave Stresen-Reuter
Monday 02 August 2004 7:45:54 pm
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
Marco Zinn
Sunday 18 July 2004 7:11:36 pm
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??
Balazs Halasy
Monday 26 April 2004 1:04:52 pm
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??
Alex Ovalle
Saturday 24 April 2004 8:21:28 pm
How do i cahnge and add new layout /design
ashok ashok
Friday 16 April 2004 9:33:34 am
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
Jason M
Thursday 23 October 2003 10:28:51 pm
{$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
Jason M
Thursday 23 October 2003 10:10:56 pm
Crashed Apache Every Time
Jason M
Thursday 23 October 2003 10:09:52 pm
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?
Steve Jackson
Sunday 31 August 2003 8:23:50 pm