Forums / Setup & design / Custom tag

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

eZ debug

Timing: Jan 18 2025 15:01:47
Script start
Timing: Jan 18 2025 15:01:47
Module start 'content'
Timing: Jan 18 2025 15:01:48
Module end 'content'
Timing: Jan 18 2025 15:01:48
Script end

Main resources:

Total runtime1.1624 sec
Peak memory usage4,096.0000 KB
Database Queries232

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.7109180.8516
Module start 'content' 0.00481.0424 769.5625847.9453
Module end 'content' 1.04720.1150 1,617.5078357.3359
Script end 1.1622  1,974.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3171210.0002
Check MTime0.00140.1246210.0001
Mysql Total
Database connection0.00070.056310.0007
Mysqli_queries1.057490.97102320.0046
Looping result0.00220.18902300.0000
Template Total1.135697.720.5678
Template load0.00200.172020.0010
Template processing1.133697.524620.5668
Template load and register function0.00010.011410.0001
states
state_id_array0.00140.122610.0014
state_identifier_array0.00130.113020.0007
Override
Cache load0.00200.17421340.0000
Sytem overhead
Fetch class attribute can translate value0.00130.115670.0002
Fetch class attribute name0.00100.0846160.0001
XML
Image XML parsing0.00230.197470.0003
class_abstraction
Instantiating content class attribute0.00000.0030190.0000
General
dbfile0.00390.3317400.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
13content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
40content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
17content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
13content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 91
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs