removing line breaks within code - helps javascript

Author Message

steve walker

Monday 21 June 2004 9:57:28 am

Hi there,

The bad news is I need your help. The good news is I should have a scrolling news box tpl to contribute when I'm done.

I have line view template code of:

{['','{$node.object.data_map.intro.content.output.output_text|striptags}','_blank'], }

which produces html of:

['','

This is an intro that gets you interested in the article

','_blank'],

but in order for the javascript to work it needs ot stay inline so it looks like:

['','This is an intro that gets you interested in the article','_blank'],

I have trawled to forums but cant see a fix to this?

Anyone know how to get code to display inline when rendered?

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Monday 21 June 2004 10:39:24 am

Try the trim operator out:

http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/string_handling#trim

Eg

['','{$node.object.data_map.intro.content.output.output_text|striptags|trim}','_blank'], }

It may work :) But i've not tried like this.

Otherwise... It looks like you are using an xml text field for this. Can you get away with a regular text field, or even better a text line?

The process of going from html to xml and back again likely introduced the spaces.

paul

--
http://www.visionwt.com

steve walker

Tuesday 22 June 2004 12:27:56 am

Paul,

Fantastic! Works a treat!

I now have a working scroller that can be used to replace the node_item toolbar latest news box - should i copy/paste the code here, or is it worth adding it into the template contributions?

Thanks for the help.

Steve.

http://www.oneworldmarket.co.uk

steve walker

Tuesday 22 June 2004 12:28:19 am

Paul,

Fantastic! Works a treat!

I now have a working scroller that can be used to replace the node_item toolbar latest news box - should i copy/paste the code here, or is it worth adding it into the template contributions?

Thanks for the help.

Steve.

http://www.oneworldmarket.co.uk

Kåre Køhler Høvik

Tuesday 22 June 2004 2:19:45 am

Great work Steve. Please post it as a contribution, so it doesn't get lost in the forum.

--
Kåre Høvik

Kåre Høvik

steve walker

Tuesday 22 June 2004 3:09:25 am

Hi,

I've created a contribute article at:

http://ez.no/community/contributions/template_plugins/vertical_latest_news_scroller

Be great if someone could test it sometime to let me know if my instructions/code make sense.

Regards, Steve.

http://www.oneworldmarket.co.uk

steve walker

Wednesday 23 June 2004 1:49:08 am

Hi there,

Was a bit optimistic with the scroller - it works in Opera and Mozilla but not in IE as IE is less forgiving with the javascript... Result is need to refine the code a little. The problem I have, taking the code that generates the data for the latest news listing, is this:

{section show=or($show_subtree|count_chars()|eq(0), $requested_uri_string|begins_with( $show_subtree ))}
{section show=$sort_by|count|eq( 0 )}{set sort_by='published'}{/section}
{let node_list=cond( $treelist_check|eq( 'yes' ),
fetch( content, tree, hash( parent_node_id, $parent_node,
limit, $limit,
class_filter_type, exclude,
class_filter_array, array( 'folder' ),
sort_by, array( $sort_by, false() ) ) ),
fetch( content, list, hash( parent_node_id, $parent_node,
limit, $limit,
class_filter_type, exclude,
class_filter_array, array( 'folder' ),
sort_by, array( $sort_by, false() ) ) ) )}

{section name=Node loop=$node_list sequence=array(bglight,bgdark)}
{node_view_gui view=listitem content_node=$Node:item}
{/section}

{/let}
{/section}

If you take the line:

{node_view_gui view=listitem content_node=$Node:item}

I need to put in a 'if...then' statement on the lines of "add the character ',' at the end of each line, unless this is the last loop in the array, in which case add nothing"

Something on the lines of:

$var = max value of the loop

{node_view_gui view=listitem content_node=$Node:item}
{section name=lastarray show=$var}

{section-else}
,
{/section}

So, a comma is all that stands between me and good java code ;)

A less elegant work around would be assume you always have enough news articles so that you utilise the '{default limit=5}' and dont add the comma on the 5th loop - this would be easier to code but creates a less robust scrolling news template.

Any pointers on thsi would be most welcome.

Thanks, Steve.

http://www.oneworldmarket.co.uk

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