Forum OpenACS Q&A: java script content feed

Collapse
Posted by Pavel Boghita on
I am looking for a way to display the links to the news items in a kind of java script ticker.
The problem so far is feeding the data into the 'var' within the java script.
Does anyone know of a good way of doing this ? i.e. generating the j.s. script dynamically.

Thanks,

Paul

I am down to passing a multirow dataset to a single variable.... I hope this makes sense
Any idea how to do this?

Thanks a lot

Collapse
Posted by Pavel Boghita on
to summarise once again:

I am using an include pair, in which I put the javascript.

The adp is ok. I define the content variable:
var scrollcontent='@vardefinedintcl@'

in tcl:
set vardefineintcl {}

now is a question of appending this vardefineintcl with the content values of an etp instance (the content of the subtopic)

I hope this makes sense.

Any help is as always much appreciated.

Thanks,

Collapse
Posted by Pavel Boghita on
On advice from Dave Bauer, I have now managed to display elements from etp, albeit only as titles in one long line:

here is my tcl code:

etp::get_content_items

etp::get_content_items -package_id 978 -result_name topics

template::multirow foreach topics {
set url [site_node::get_url_from_object_id -object_id 978]${url}
append content "${title} ${url}"

}

in the adp within the scrip part I have:

var scrollercontent='@content@'

the result is a succession of all the titles and urls for package_id 978.

Does anyone know of a way to separate the items within 'content' so I can control the display ?
I've tried append content "${title} ${url}
" for example but
is not interpreted.

Thanks

Collapse
Posted by Pavel Boghita on
i meant < br > is not interpreted
Collapse
Posted by Steve Manning on
When you say not interpreted do you mean that you can see the &lt;br> tag when the page is displayed.

If so try

var scrollercontent='@content;noquote@'


- Steve

Collapse
Posted by Pavel Boghita on
Steve, thanks a million.

I'll give my tcl for future reference:

# /packages/edit-this-page/templates/article-index.tcl

#etp::get_page_attributes
etp::get_content_items

etp::get_content_items -package_id 978 -result_name topics

template::multirow foreach topics {
  set url [site_node::get_url_from_object_id -object_id 978]${url}
  append content "<a href=\"$url\"> $title </a> <br>"

Collapse
Posted by Pavel Boghita on
Then you can use the content variable within your java script in the adp page that does whatever scrolling you fancy. There are loads on the web, the one I've used is here: http://www.hypergurl.com/verticaltext.html
Collapse
Posted by Jade Rubick on
An even better way to do this would to use Ajax, which means your Javascript gets the dynamic data itself.
Collapse
Posted by Dave Bauer on
Jade,

Sure, something like mod_pubsub http://www.mod-pubsub.org/