Forums / Developer / How to wash an xmltext to populate an input field ?

How to wash an xmltext to populate an input field ?

Author Message

Xavier Dutoit

Wednesday 10 May 2006 9:42:47 am

Hi all, washing day today for me ;)

I want to use the content of an xmltext field to populate an input field.

eg <input type="hidden" value=" Things that come from a xml field">

I did try to use the (undocumented) wash(javascript) like that:

<input type="hidden"
  name="powercontent_intro_ContentObjectAttribute_data_text_pcattributeid"
  value='{$node.object.data_map.intro.content.output.output_text|wash(javascript)}' />

At least it solves the " let's go" problem (ie it doesn't stop the input value after the ' . However, it does replace the " by a \047 that isn't what is expected.

Are you aware of a wash thing that I could use for that ?

On a related problem: how do you use the xmlfield to populate a title tag ?

eg <a href="{$node.url_alias}" title='{$node.object.data_map.intro.content.output.output_text|strip_tags|wash(javascript)}' />

The result is not that good either.

Many thanks for your inputs and suggestions.

X+

http://www.sydesy.com

Kristof Coomans

Wednesday 10 May 2006 10:25:59 am

Hi Xavier

I don't know about a suitable washing operator to do this, but if it doesn't exist yet then maybe we can create our own? As I see it, I would just traverse the dom tree and append all text nodes to each other.

Didn't know there was a strip_tags operator either. Is it documented somewhere?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Łukasz Serwatka

Wednesday 10 May 2006 10:38:01 am

@Kristof
You can define it in template.ini.append.php

[PHP]
# A list with php functions and their equivelant template operator names
# Giving the operators a different name from the PHP functions
# are recommended, that way you ensure that all operators follow
# the same naming guidelines. It also means that you can change the
# php function later on without doing template changes.
PHPOperatorList[striptags]=strip_tags

Where value is name of PHP function.

@Xavier:

In many cases $content|wash is sufficient. Have you tried?

EDIT:
On community home page links to last forum topics uses:

{...content|wash|shorten( 400 )}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Wednesday 10 May 2006 10:52:37 am

@Lukasz

Ok, I put " (double quote) instead of single onces and wash without additionnal parameter and it seems to work (so far).

<input type="hidden"
name="powercontent_intro_ContentObjectAttribute_data_text_pcattributeid"
value="{$node.object.data_map.intro.content.output.output_text|wash()}" />

Thanks for the help !

@Kristof,

I use it to populate attributes with powercontent. Works great !

@Who wants to listen.

The strip_tag operator is really mandatory in quite a lot of cases, even if it is far to be perfect. For instance, you can't use the shorten operator without it on a xmltext (otherwise, you're going to have your text cut between two tags with quite funny result).

Still don't get why it isn't standard in ez. Who should we beg/bribe/beat with a stick so it's included in the default ?

X+

http://www.sydesy.com

Xavier Dutoit

Wednesday 10 May 2006 10:57:26 am

@Lukasz

{...content|wash|shorten( 400 )}

I did remember having used it and it didn't make it. Can't remember now what was the pb. Does it works with all the tags ?

I had to do

{...content|strip_tags|wash|shorten( 400 )}

EDIT:

Looking at the code that was problematic, I shorten it first and then wash (I know, that's stupid). I'm going to give the wash only option.

X+

http://www.sydesy.com

Łukasz Serwatka

Wednesday 10 May 2006 11:09:24 am

Yes, you are right Xavier. Forum uses text filed so no tags in output by default (as long as user will include something), on ezxml filed you need to use striptags other way you will have xhtml tags in the output.

e.g

{$node.object.data_map.short_description.content.output.output_text|striptags|wash|shorten( 400 )}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Wednesday 10 May 2006 11:12:39 am

@Lukasz,

Is the wash|shorten(lenght) used as well in the content/new ?

In that case, I see the problem:

It truncates after the first paragraph (or so it seems),

As quite a few post start with, <p>Hi</p> or <p>@Someone</p> it doesn't give a very usefull title, even so that would be possible to put more chars and stay under lenght.

I think it was why I strip_taged the content first.

X+

http://www.sydesy.com

Łukasz Serwatka

Wednesday 10 May 2006 11:15:23 am

I guess you use Firefox which does not understand new lines in title. Under Opera and IE works fine.

EDIT:
See comments here:
http://ez.no/community/blog/small_forum_update

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Thursday 11 May 2006 1:40:42 am

Indeed I use firefox.

I think I'll stick to strip_tags for now, until FF changes its behaviour.

Thanks,

X+

http://www.sydesy.com

Paul Forsyth

Thursday 11 May 2006 1:57:46 am

In the past i've used this tool to get cross-platform support:

http://www.walterzorn.com/tooltip/tooltip_e.htm

As its is js there is some overhead but it depends on what you need to do.

Paul

eZ debug

Timing: Jan 18 2025 22:19:58
Script start
Timing: Jan 18 2025 22:19:58
Module start 'content'
Timing: Jan 18 2025 22:19:58
Module end 'content'
Timing: Jan 18 2025 22:19:58
Script end

Main resources:

Total runtime0.1874 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 591.7109180.8125
Module start 'content' 0.00790.0108 772.5234110.0547
Module end 'content' 0.01860.1687 882.5781539.1250
Script end 0.1873  1,421.7031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00371.9789200.0002
Check MTime0.00140.7394200.0001
Mysql Total
Database connection0.00120.627010.0012
Mysqli_queries0.126067.22651410.0009
Looping result0.00150.77751390.0000
Template Total0.168289.710.1682
Template load0.00090.466410.0009
Template processing0.167389.278410.1673
Override
Cache load0.00060.319710.0006
Sytem overhead
Fetch class attribute can translate value0.00090.468610.0009
XML
Image XML parsing0.00030.137210.0003
General
dbfile0.01226.5332200.0006
String conversion0.00000.002230.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0003 secs