Custom tags

In this example the tag being added is 'mynewline'.

1. Add your file that is the same name as your tag to design/user/templates/content/datatype/view/ezxmltags
in this case lets call it mynewline.tpl.

Note 1. If the directory structure does not exist, create it.
Note 2. This assumes you have you design data under 'user' and not another name. Of course you can change this.

2. Edit mynewline.tpl and place your HTML in it.. i.e.

<br />

3. Add custom tag to content.ini.php file so it is available to the online editor, if you are using it.

[CustomTagSettings]

AvailableCustomTags[]=mynewline

4. If the tag is meant to be in-line, you should also add the following to your content.ini.php:

[CustomTagSettings]

IsInline[mynewline]=true

Usage:
Place the following in any XML field.

<custom name='mynewline'>

 

</custom>

Example:
To display text in a different colour change your mynewline.tpl to

<div style="color: red">{$content}</div>

Note. If you set the color of text in your css "p" tag, the above will not work as eZ places a

<p>

after your style, thus blocking it.

and add the following to your XML field.

<custom name='mynewline'>

This should be red

</custom>

Of course you may want to change the name of the XML tag to something more relevant.

Update: As of version 3.2 aditional arguments to the custom tag is supported. You can e.g. use:

<custom name='mynewline' color='blue'>

This should be blue

</custom>

The color will then be available as a variable in the template.

NOTE: remember to clear the override cache whenever you add a new tag. This can be done with

./bin/shell/clearcache.sh --clear-all

Comments

Custom Tags with other nested tags inside...

How does someone create a custom tag that might contain other tags inside of it, such as emphasis or strong?

If you try to put nested tags inside of a custom tag in an XMLTextField the server will come back with the ole:



Tag 'strong' is not allowed to be the child of 'custom' (removed);


In-line tags

If you are adding a custom tag that should be in-line (i.e. not wrapepd with paragraph tags), make sure to add the following to your content.ini under [CustomTagSettings]:



IsInline[YOURTAGNAME]=true


more attributes

If i want create <acronym title="myacronym">myword</acronym> ?

Shorting custom tags down...

When editing articles in the Admin "<custom name='mynewline'></custom>" is pretty much code for a simple <br>.. Is there any way to short this down, or do we have to invest in the online editor? :)

Log in or create a user account to comment.

Contents

Customization

Access control
Exponential API Documentation
Content structure
Custom design
Components
    Images
    Datatypes
       eZXMLText
          Custom tags
          Tags
          Classification
       eZKeyword
       eZObjectRelation
    Shop
    Information collection
    Search
    Form processing
    Error handling
    Icons
    Menus
    Toolbars
Tips & Tricks
Troubleshooting


Created

23/04/2003
6:45:10 pm
by B�rd Farstad

Last updated

17/02/2004
4:12:27 pm
by Alex Jones

Authors

B�rd Farstad
Thierry MADILLO
Tony Wood
Alex Jones



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