include
Summary
Includes a file.Usage
{include uri='path_to_file' [ name='namespace' ] [ parameter(s)='value(s)' ]}
Parameters
Name | Type | Description | Required |
---|---|---|---|
uri | string | Path + name of the file that should be included. | Yes. |
name | string | Alternative namespace for the included template. | No. |
other parameters | any | Parameters that will be passed to the included template. | No. |
Description
This function includes a file in the template from where the function was called. The "uri" parameter must be used to specify the target file. In most cases, the value of this parameter starts with a "design:", which tells the system to look for the desired template within the current (and fallback) design resources. The "name" parameter can be used to specify an alternative namespace for the included template, this is useful for avoiding variable name clashes when including other templates. All other parameters will be passed to the included template as template variables. This function makes it possible to share template code among different parts of the solution.
Examples
Example 1
{include uri='design:example/menu.tpl' something='Hello world'}
This example demonstrates how to include a template called "menu.tpl" (which is located within the "example" subdirectory of the "templates" directory. If eZ Publish is unable to find the template in the current design, it will automatically attempt to locate it in one of the fallback designs or the standard design. The value of the "something" parameter will be available through a variable called $something within the template that is included.
Balazs Halasy (06/02/2004 1:19 pm)
Balazs Halasy (28/04/2005 1:55 pm)
Comments
What schemas does the URI attribute support
Monday 26 September 2005 1:52:56 am
James Robertson
What are the 'other' cases? Does this function support other URI schemas such as 'http:'?
Re: What schemas does the URI attribute support
Sunday 01 November 2009 11:35:51 pm
Gaetano
Include limits
Tuesday 21 February 2006 10:48:27 pm
James Ward
Re: Include limits
Monday 27 February 2006 7:16:55 pm
Bertrand Dunogier
Yes
- Can I include within an override?
Yes
- Can I include the same file within itself?
Yes
Can I use include with...
Wednesday 28 February 2007 3:33:58 pm
P. Renaud
- an array as parameter value ? Yes !
- a hash array as parameter ? Yes !
- a node ? Yes !
Inlude templates located into override
Saturday 17 May 2008 3:57:34 pm
Seb
Is there anyway to include a template located into mydesign/override/templates/... by using this function ?
I do not succeed although I tried several syntax...
Re: Inlude templates located into override
Thursday 28 August 2008 10:44:38 am
André R.
Re: Re: Inlude templates located into override
Tuesday 28 July 2009 4:15:56 pm
Adrien
Re: Re: Inlude templates located into override
Thursday 28 January 2010 2:13:38 pm
pike
{include uri="file:design/yourdesignhere/override/templates/yourstuff.tpl"}
worked,
*-pike
Name spaces
Wednesday 01 April 2009 3:40:16 pm
Claudio B.
Maybe it's because any include literaly inject code in template?
Should I edit any included files from admin.
Wednesday 02 December 2009 6:30:24 am
test
Please suggest.
Not really agree with 'includes a file'
Wednesday 30 December 2009 3:36:26 pm
GX Admin
If you want to include the content of a CSS file for example, all css brackets { } will be executed like template instructions (and a template engine crash will occur... blank page...).
There is no way to indicate that the file is not a tpl one (so a literal content instead) ?
I want to include the content of a file (like a CSS one) which has no {literal} tag inside (I cannot add it myself).