eZ Community » Forums » Developer » Output XML without embedded objects...
expandshrink

Output XML without embedded objects via attribute_view_gui

Output XML without embedded objects via attribute_view_gui

Thursday 13 September 2007 2:15:13 am - 10 replies

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!

Thursday 13 September 2007 10: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/documentat...lopment/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}

Monday 17 September 2007 8:20:58 am

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

Monday 17 September 2007 9: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 sad.gif Emoticon

Tuesday 18 September 2007 6:48:50 am

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.

Tuesday 18 September 2007 10: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.

Modified on Thursday 20 November 2008 11:52:07 am by Peter Putzer

Wednesday 19 September 2007 1:44:58 am

# 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

Wednesday 19 September 2007 10: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.

Wednesday 19 September 2007 12:15:01 pm

#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.

Wednesday 19 September 2007 1:27:52 pm

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).

Tuesday 16 December 2008 10: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 happy.gif Emoticon

Modified on Tuesday 16 December 2008 10:36:29 am by Peter Putzer

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from