Custom tag

Author Message

Pascal France

Thursday 23 November 2006 7:38:59 am

Hi,

I want to understand how do work custom tags. So I'm trying to create an "underline" tag with a class.

In settings/siteaccess/ezwebin_admin/content.ini.append.php I put:

[CustomTagSettings]
# You can use custom tags through the <custom> tag in XML fields.
# Example: <custom name="sub">Sub text</custom>
AvailableCustomTags[]=underline
IsInline[underline]=true

[underline]
AvailableClasses[]
AvailableClasses[]=red
AllowEmpty=false
CustomAttributes[]

I created a customtag template:
design/standard/templates/content/datatype/view/ezxmltags/underline.tpl which contains:

<u>{$content}</u>

And I created a class in extension/ezwebin/design/ezwebin/stylesheets/css_moi.css (I'm using a 3.9rc1):

.red {
    color: red;
    font-size: 2em;
}

Well, I think all is right.

In OE I can see my "underline" customtag but when I close the tag edit window the text is not undelined but it is well underlined when I publish the article.
eg: this is what I see in OE before publishing:

This is my undelined text example.

After I publish the article, I can see in the view mode of the admin interface:

This is an <u>underlined</u> text example.

and in the public site:

This is an
<u>underlined</u>
text example.

So, I have some questions:

1°/ Why the text is not underlined in OE ?
2°/ Why the source code of the public page contains <p></p> tags around the underlined text ?

<p>
This is an 
</p>
<u>underlined</u>
<p>
 text example.
</p>

3°/ What must I do to use the class "red" with my tag ?

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Thursday 23 November 2006 11:26:46 am

Hi,

I found this tuto:
http://ez.no/products/ez_publish/documentation/customization/components/datatypes/ezxmltext/custom_tagsand and now I know how to add red underlined text.

But isn't really no way to display just one word in red in a sentence ?

And why can we have juste one striked, strong or italic word in a sentence and not juste one underlined word ? (with "underline" the sentence is broken before and after the underlined word)

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Thursday 23 November 2006 2:28:25 pm

Hi,

Well, I found a solution: classes for strong (bold) elements ;-)
But I have a problem: the classes are well displayed in the drop-down list of the properties window but they are not added to the code.

This method works fine with paragraphs and should work with bold texts (it is writen in the official doc) but it doesn't.
If I add the class by hand (once I disable OE) and publish the article I get the right result:

http://www.vistacite.fr/BBB/index.php/plain/a_voir_dans_la_region/new_article__2

Do I miss something again ?

Regards

Pascal

PS: I use OE 4.1.2 with eZP 3.8.4

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Aurélien DESNEUX

Tuesday 23 January 2007 7:42:23 am

<p>
This is an
</p>
<u>underlined</u>
<p>
text example.
</p>

Hi pascal ! I have got the same probleme ! I use OE 4.2 with Ez 3.8.9.

How can I solve this ?

Carlos Revillo

Tuesday 20 February 2007 6:19:10 am

Hi all. I had the same problem when i tried to add abbr elements in my code. In mysettings/siteaccess/admin_section/content.ini.append.php I put something like:

[CustomTagSettings]
AvailableCustomTags[]=abbr
IsInline[abbr]=true
CustomAttributes[]
CustomAttributes[]=title

and i also get something like

<p>The next</p>
<abbr>word</abbr>
<p>is an abbr</p>

What i did is add the same [CustomTagSettings] for mysettings/siteaccess/public_section/content.ini.append.php

[CustomTagSettings]
AvailableCustomTags[]=abbr
IsInline[abbr]=true
CustomAttributes[]
CustomAttributes[]=title

and now i get

 
<p>The next <abbr>word</abbr> is an abbr</p>

I don't really know if this is the best solution, but it worked for me... Hope it helps.

Betsy Gamrat

Monday 05 March 2007 12:03:42 pm

Hi,

This thread helped me, and I'm posting additional information.

These are the files to modify, and examples of what to put in them to add a custom color tag to the OE.

<b>siteaccess/new/override.ini.append.php</b>

[color]
Source=content/datatype/view/ezxmltags/color.tpl
MatchFile=datatype/ezxmltext/color.tpl
Subdir=templates

<b>override/content.ini.append.php</b>

[CustomTagSettings]
AvailableCustomTags[]=color
IsInline[color]=true

[color]
AllowEmpty=false
CustomAttributes[]
CustomAttributes[]=color
CustomAttributesDefaults[]
CustomAttributesDefaults[color]=black

<b>ez/design/base/override/templates/datatype/ezxmltext/color.tpl</b>

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

Thanks to the previous posters and I hope this helps the next visitors.

<b>:)</b>

Heath

Monday 05 March 2007 5:44:43 pm

This is a good thread with many examples from custom users needs.

Some of these might be better served as examples within eZpedia. http://ezpedia.org/wiki/en/ez/custom_tag

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Bruce Morrison

Monday 05 March 2007 8:03:31 pm

@Betsy
I don't think you need the override. color.tpl can go in
ez/design/base/templates/datatype/ezxmltext/color.tpl

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Heath

Monday 05 March 2007 9:45:28 pm

Interesting side question ... are template overrides defined in ini settings faster than without, is the difference negligible after template and override caching ..

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Bruce Morrison

Monday 05 March 2007 10:22:04 pm

Hi Heath

Can't see there being a big difference. Though I would say that the less entries in override.ini the better.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Betsy Gamrat

Wednesday 07 March 2007 5:22:12 am

Bruce,

You're probably right about not needing the override. I posted what worked for me.

You can also add this code to <b>extension/ezdhtml/design/standard/stylesheets/ezdhtml/editor_classes.css</b> to set the background color of the <i>custom-color</i> elements. This makes it easier for editors to identify text that is under the effect of the custom-color tag.

span.custom-color
{
background-color:#eee;
}

:)

Pascal France

Thursday 08 March 2007 3:44:33 pm

Hi Betsy,

Thanks for your contribution ;-)

I'm using OE 4.1.2 with ezp 3.8.4 and I have a little problem with the $color variable in

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

because it is always empty, so, in the source code of the html public page, I get that:

<span style="color:">This is my black text</span>

In color.tpl, if I write the color:

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

then all works fine.

In
settings/siteaccess/plain/content.ini.append.php
and
settings/siteaccess/plain_admin/content.ini.append.php
I put the same code:

[CustomTagSettings]
AvailableCustomTags[]=color
IsInline[color]=true

[color]
AllowEmpty=false
CustomAttributes[]
CustomAttributes[]=color
CustomAttributesDefaults[]
CustomAttributesDefaults[color]=black

As this doesn't work, I tried to put this code in settings/override/content.ini.append.php without more success.

There is another strange thing: in the admin interface, when I select my article (it is not edited, just selected) I can see its containt but the text which is affected by the "color" custom tag is not displayed. It is displayed if I edit the article.

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Thursday 08 March 2007 4:24:46 pm

Ok, I founded how this custom tag works: we have to use the "New attribute" button...

However, there remain two things :

- the coloured words which are not displayed in the admin interface when the article is not edited (see my previous post),
- there is always a space after the </span> end tag, so you we can't color juste one letter in a word with this method and the final point of a sentence will always be separated from the last word by a space. Maybe can we do a modfication in a file to fixe this problem ?

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.