{literal} in articles?

Author Message

Jeroen Sangers

Friday 09 June 2006 8:47:50 am

Sometimes I want to enter some literal HTML or JavaScript text on a page, for example when I want to add a little tracking code to measure the result of an advertising campaign. At this moment the only way of doing so is by generating a template override for that specific page and enter the page there. That is a lot of work! Besides that, it is still impossible to add HTML in the middle of a text.
Is there really no way to have the equivalent of {literal} work inside articles?

Marcin Drozd

Friday 09 June 2006 3:07:38 pm

Hi Jeroen
It works with:

<literal class='html'>
some code
</literal>

http://ez-publish.pl

Jeroen Sangers

Wednesday 14 June 2006 2:15:43 am

Thanks! I must have read over it when I checked the documentation.

Ciprian Popovici

Wednesday 14 June 2006 2:23:11 am

The only thing <literal> does is create a <pre> block and apply wash() to everything in it. Doing class='blabla' only produces a <pre class='blabla'>, with everything inside it still washed.

Jeroen, I'm thinking you could accomplish this by creating your own custom tag, as well as an "unwash" eqivalent, some kind of reverse wash.

<b>Step 1:</b> Go in <b>both</b> the admin siteaccess and in the siteaccess you want to use this, and add this to custom.ini.append.php (create them if they don't exist):

[CustomTagSettings]
AvailableCustomTags[]=html
IsInline[html]=true

<b>Step 2:</b> Go to settings/override/template.ini.append.php and create an unwash function:

[PHP]
PHPOperatorList[unwash]=html_entity_decode

<b>Step 3:</b> Create the override, by going to design/yoursite/templates/content/datatype/view/ezxmltags/ and creating html.tpl with this in it:

{$content|unwash()}

<b>Step 4:</b> Clear your ini cache (possibly your template cache too).

<b>Step 5:</b> In the admin interface, every time you edit an XML block you can now add something like this:

<custom name='html'>&raquo;</custom>

...or whatever other HTML you want.

Jeroen Sangers

Wednesday 14 June 2006 2:49:22 am

That is not true!
The solution provided by Marcin Drozd works perfectly. It does not create a PRE block, but enters the provided code directly into the final page. There is no need to set up custom tags.

Marcin Drozd

Wednesday 14 June 2006 7:04:28 am

Hi guys
Yes,
<literal> creates <pre> tag, but
<literal class='html'> does not create <pre> tag.

http://ez-publish.pl

Ciprian Popovici

Thursday 15 June 2006 4:58:21 am

What ez Publish version are you using? On my 3.7.2 install, if I put HTML tags or HTML entities inside <literal class='html'></literal>, they end up escaped. Perhaps it's something else I'm missing? Did you guys override your literal template to do that?

If I put this in an XML block:

<literal class="html"><u>&raquo;</u></literal>

It will be rendered as:

<pre class="html">&lt;u&gt;&amp;raquo;&lt;/u&gt;</pre>

and NOT like this:

<u>&raquo;</u>

...thus negating the original request: ability to enter HTML or JavaScript code.

Jeroen Sangers

Thursday 15 June 2006 7:12:43 am

I am using eZ Publish 3.8.

Ciprian Popovici

Thursday 15 June 2006 7:24:07 am

Ah, there you go. They must've added this in 3.8. Anyway, for 3.7 users you have to resort to tricks like above. You could override the template for <literal> (haven't tried it), test for $class being "html" and apply unwash() on $content if it matches.

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

eZ debug

Timing: Jan 18 2025 19:35:09
Script start
Timing: Jan 18 2025 19:35:09
Module start 'layout'
Timing: Jan 18 2025 19:35:09
Module start 'content'
Timing: Jan 18 2025 19:35:10
Module end 'content'
Timing: Jan 18 2025 19:35:10
Script end

Main resources:

Total runtime1.0640 sec
Peak memory usage4,096.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.0234152.6250
Module start 'layout' 0.00580.0029 741.648439.4297
Module start 'content' 0.00871.0536 781.0781641.6328
Module end 'content' 1.06220.0017 1,422.710920.1875
Script end 1.0639  1,442.8984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2909160.0002
Check MTime0.00130.1191160.0001
Mysql Total
Database connection0.00070.068910.0007
Mysqli_queries0.996093.6123770.0129
Looping result0.00080.0784750.0000
Template Total1.032697.120.5163
Template load0.00240.223620.0012
Template processing1.030296.827320.5151
Template load and register function0.00010.011210.0001
states
state_id_array0.00120.110510.0012
state_identifier_array0.00250.236620.0013
Override
Cache load0.00190.1804490.0000
Sytem overhead
Fetch class attribute can translate value0.00060.060930.0002
Fetch class attribute name0.00110.1067100.0001
XML
Image XML parsing0.00070.067730.0002
class_abstraction
Instantiating content class attribute0.00000.0023130.0000
General
dbfile0.00080.0795160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 43
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs