Share » Forums » Developer » How to wash an xmltext to populate...

How to wash an xmltext to populate an input field ?

How to wash an xmltext to populate an input field ?

Wednesday 10 May 2006 9:42:47 am - 9 replies

Author Message

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

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

36 542 Users on board!

Forums menu