eZ Community » Forums » Developer » specifying the css class to be used...

specifying the css class to be used in the xml tags (i.e <strong>,<emphasize>) when provided in the xml text field.

specifying the css class to be used in the xml tags (i.e <strong>,<emphasize>) when provided in the xml text field.

Saturday 28 June 2003 12:08:27 pm - 7 replies

Hello Everyone,

Is there a way of providing the class in the xml tags supported by eZPublish for the xmltextfield i.e <strong class='thestyle'> </strong> or <emphase class='a_class_in_css'></emphase>. Actually i dont want to fix the colour in the tpl used for these tags 'in the ezxmltags dir' (which i can always do,with the use of class defined in css) but i want to give this leverage to the user entering the data.

I know it could be done through the use of custom tag option but the thing is that custom places the contents/data following it on a new paragraph/line which i dont want to, otherwise i would have adopted this option.

Suggestions plz


Saturday 28 June 2003 5:08:42 pm

i guess you've read:


From what i've gathered with 3.1 there is space to add a class. If you've installed 3.1 have a look at the manual and everyday functions for tag information that mentions this. Ez haven't updated their own ez.no/manual site yet with new 3.1 docs.


Modified on Saturday 28 June 2003 5:10:30 pm by Paul Forsyth

Sunday 29 June 2003 1:07:42 pm

Thanks for the reply Paul, but i am using 3.0.2 version of eZPublish, isn't there any option for doing the same in it.

Sunday 29 June 2003 5:13:03 pm

Ah, i see.

Ok, two ways to proceed.

First would be to look at the tpl files that the xml datafield uses to display its information. Theses are usually within:


You could override these tpl files in your design and add class tags where you wish.

The fallback approach would be to look at the html output and wrap the code, like you did with the input fields, with html specifying a css class to override anything the xml datafield does. Takes a little to play with but does work. Sometimes I find i have to go back and forward from the html source to fine tune it. In this way i can make headings and things are as i like.

Once you get used to way css works for this type of thing it becomes easier to use.


Monday 30 June 2003 1:27:58 pm

Thanks again Paul that was indeed of help, but in both the case which u have suggested, it would something hardcoded, where the same style sheet class would be used for a perticular tag, for example if i hard code the class in the .tpl file for the <strong> tag (in the ezxmltags dir or in the .tpl used for rendering the page) the same style sheet would be applied everytime i use this tag in the xmltextfield in any of the pages/nodes.

I am looking for something dynamic, where the user has more control of the presentation.

Thanks in advance.

Monday 30 June 2003 4:06:42 pm

I see your point.

But this is where some ez features come in handy. The second method I mentioned involved wrapping a css class around the code to display the xml field.

You can perform tests within the tpl code to make sure that your css class is only used when you want it. For example:

{section name=TestArticle show=eq($node.object.contentclass_id, 1)}
<td class="strong">
{attribute_view_gui attribute=$node.contentobject_version_object.data_map.heading}

Here the first statement will only show if the current article node is a folder. You can make this kind of check more specific if you wish, choose your new class, etc. I hope you see what is possible here.


Modified on Monday 30 June 2003 4:07:38 pm by Paul Forsyth

Tuesday 01 July 2003 9:23:17 am

Well this seems to be a good option where you can provide some of the dynamic functionality i am looking for, but then again what if the tag (e.g. <strong>blunk.gif Emoticon has been used twice in the same XMLtextfield (in a Node/ContentObject) and for one of them i want the text in the <strong> tag to be shown in blue colour and in the other in green. I doubt there would be any flexibility in doing such a thing??, the suggestion you have given would be restricted to just one perticular type of node.

Thanks again.


Tuesday 01 July 2003 10:13:19 am

As i mentioned you can specialise this in any way you wish so adding more logic to make the cases more specific is possible.

But its a list of trade offs. On one hand you have 3.1 and on the other the time spent working out the logic to make sure only certain classes get used. In our code we use a lot of logic to present menus and the like to users.

The upgrade path isn't too difficult to be honest blunk.gif Emoticon



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from