Output XML without embedded objects via attribute_view_gui

Author Message

paul bolger

Wednesday 12 September 2007 5:15:13 pm

I'd like to output XML from an attribute but not include images (or embedded objects, for that matter).

I realise that you can extract the raw text and strip the XML formatting, but would like to preserve the formatting.

I guess my problem is that I'm finding it hard to see how the various templates that are invoked by attribute_view_gui call their sub-templates. I suppose one option would be to override /ezimage.tpl and just refer to an empty file, but that seems inelegant.

Does anyone know an easy way to do this?

BTW - An article on visualisation would be really handy!

Paul Bolger

Damien Pobel

Thursday 13 September 2007 1:11:13 am

Hi Paul,

Write a custom template operator that strips img or whatever is probably the easier way to do that.
http://ez.no/ezpublish/documentation/development/extensions/template_operator

and then in your template you can do :

{attribute_view_gui attribute=$your_attribute strip_img=true()}

and in an override of templates/content/datatype/view/ezxmltext.tpl you can do

{if and( $strip_img|is_set, $strip_img )}
{your_operator( $attribute.content.output.output_text )}
{else}
{$attribute.content.output.output_text}
{/if}

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Xavier Dutoit

Sunday 16 September 2007 11:20:58 pm

This extension should do it (look at the strip_tags exemples)
http://projects.ez.no/xmlwash

http://www.sydesy.com

Peter Putzer

Monday 17 September 2007 12:12:49 am

It doesn't, if your goal is to get a standard formated text just without embedded objects. For example, image descriptions will become part of the text if just strip out the tags around them.

My solution is to use a regular expressions template operator to strip out the complete rendering of the <i>embed</i> tag. However, this is not a very robust solution. Filtering of the source XML would be a better angle, or the ability to give parameters to the <i>ezxmltags</i> templates.

Unfortunately, at the moment there is no template operator to parse a given simple XML string to XHTML via templates and no way to pass parameters.And you can't override the <i>ezxmltags</i> templates for a specific viewmode, either :(

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

paul bolger

Monday 17 September 2007 9:48:50 pm

Thanks all. It sounds like I may have to continue with my striptags solution, and hope the users don't try using lists in the first part of their XML.

Another solution to my problem - I need to be able to use bits of the short description in trimmed 'highlights' on the front page of my site, and having images turn up would be horrible - would be to change the short description field to plain text. I think maybe for what short description is intended - a brief summary of the page - XML is not really appropriate.

Paul Bolger

Peter Putzer

Tuesday 18 September 2007 1:01:10 am

Well, I need that functionality myself. Currently, I'm using a combination of the <i>teaser</i> operator provided by the <i>xmlwash</i> contribution and a regular expression to clean out embedded objects (mainly images), as well as other extraneous tags (for example, I use special <i>span</i> tags to mark external links for screenreader users.

So maybe I'll write an operator to do such cleanups in a well-defined way on the XML level. Will take some time, though.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

paul bolger

Tuesday 18 September 2007 4:44:58 pm

# So maybe I'll write an operator to do such cleanups in a well-defined way on the XML level. Will take some time, though.

That'd be really handy.

By the way - are you making users add images as attributes, adding them as relations, or pulling them from the embedded XML?

Or 'all of the above' !

regards

Paul Bolger

Peter Putzer

Wednesday 19 September 2007 1:33:18 am

Are you referring to the thumbnails at http://pluspunkt.at ? I generate them from the embedded images in the XML code (via the "embedded" relation). If there are none, blog entries get the author portrait instead. Generally, the page looks better if all teasers have a thumbnail, so I'm thinking of adding an attribute for folders to provide default thumbnails for alle kinds of news.

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

paul bolger

Wednesday 19 September 2007 3:15:01 am

#Are you referring to the thumbnails at http://pluspunkt.at ?

Yes, sorry I should have been clearer. On the site I've been working on (alicesprings.nt.gov.au) I originally intended to get users to add images via an image attribute, but kept getting "but I've already put an image in the story" from my content editors. So I think I'll have to test first for an embedded image, than an attribute image, then go to a list of fallback images, or maybe a list for articles and for calendar items - the two classes I'm allowing as possible highlights/teasers. The attribute image is handy if the first image in the XML really doesn't work when its been butchered by Imagemagick.

Re. tagging the folders: getting the editors to categorise the story when they put it in is nice in theory, but I find nine times out of ten they'll put 'general' if it's offered.

Paul Bolger

Peter Putzer

Wednesday 19 September 2007 4:27:52 am

Tagging> Ah, well, <i>that</i> is not a problem at the moment, as I'm my own editor currently. I can't even get the people writing the content to use their eZ Publish account at the moment. Though I hope with the integration of the ezwebin toolbar, this will change.

Default images> Mhm... doing it by class (configured using an ini-file) would be a possibility, too. I currently have plain articles, events (custom class based on article) and press releases in the news column (left).

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

Peter Putzer

Tuesday 16 December 2008 1:36:04 am

If anyone is still interested, I whipped up an extension yesterday that uses the "Alias" feature to replace the default XHTMLOutputHandler for ezxmltext. Unfortunately, I don't see a way to get the "view" parameter from ezxmltext.tpl to the ezxmtags/*.tpl, so I can't add an override key for it.

However, if you use

{$node.data_map.MY_ATTRIBUTE.content.output.output_text}

directly in your node view templates, you can simulate the "view" parameter by calling

{$node.data_map.MY_ATTRIBUTE.content.output.output_text_VIEW}

instead.

As far as I can see, there are no sideeffects and you can define as many "views" as you like (via ezxml.ini). The new override key for ezxmltags is called "attribute_view_mode". I hope I'll be able to dress up the extension for publishing tonight. So, tell me if you're interested :-)

Accessible website starting from eZ publish 3.0 (currently: 4.1.0): http://pluspunkt.at

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