 |

jo
Novice
Jul 18, 2002, 7:22 AM
Post #1 of 16
(9099 views)
Shortcut
|
Hi I want to use a newsticker on my website. Is it possible to pull data out of the article manager database and use it in my ticker. For exemple: I want to rotate the latest headlines. Where can i find the plain txt files for inserting automaticly in the ticker code? Thanks
|
|
|  |
 |

dlo_itools
Staff

Jul 18, 2002, 2:03 PM
Post #2 of 16
(9088 views)
Shortcut
|
Although there isn't a plain text file of article headlines, the category index files cat_index_N.html in the publish/ directory is the closest to plain text as you get. A quick filter (in Perl or in your favorite text processing language) can transform that into a text file of headlines. Here's an example filter in Perl: # usage: perl getheadlines.pl <cat_index_1.html >cat1.txt while ($line=<>) { if ($line =~ m|<font class="artname">(.*?)</font>|) { $line = $1; $line =~ s|<[^>]*>||g; print "$line\n"; } } The remaining parts of integrating this with the newsticker and running the script regularly is left as a value-add for fellow web developers ;) /Dave Lo
|
|
|  |
 |

jo
Novice
Jul 18, 2002, 11:48 PM
Post #3 of 16
(9076 views)
Shortcut
|
Thanks I'm gona give it a try.
|
|
|  |
 |

MalaK_3araby
User
Jul 27, 2002, 6:50 PM
Post #4 of 16
(9026 views)
Shortcut
|
News Ticker is an awsome idea. I have never done Perl before, where should this go? More specific instructions Please. -------------- Sure you can spell it, but do you get it?
|
|
|  |
 |

dlo_itools
Staff

Jul 29, 2002, 10:15 AM
Post #5 of 16
(9008 views)
Shortcut
|
|
Re: [MalaK_3araby] News ticker
[In reply to]
|
Can't Post
|
|
To use the above script to generate a text file of headlines, do the following: ---- Saving the script: 1. Save the above script with the filename getheadlines.pl in your artman/publish directory. 2. Edit the script to add the following as the first line #!/usr/bin/perl ---- Using the script: 1. Go to your article manager directory chdir artman/publish 2. Run the script with perl, putting in the categories perl getheadlines.pl cat_index_1.html cat_index_2.html >headlines.txt Now you will have a text file of the headlines from categories 1 and 2. /Dave Lo
|
|
|  |
 |

noza
User
Aug 13, 2002, 8:21 PM
Post #6 of 16
(8908 views)
Shortcut
|
|
Re: [MalaK_3araby] News ticker
[In reply to]
|
Can't Post
|
|
Hi, didi you get this working ? could you tell us where ? Pat
|
|
|  |
 |

MalaK_3araby
User
Aug 14, 2002, 10:41 AM
Post #9 of 16
(8883 views)
Shortcut
|
Thank you dave i will try that. how would i modify the output to add html to achive this: <table bgcolor=#ECECEC><tr> <td><a href="...">artname</a>someHTML</td> .:. <td>someHTML</td></tr></table> I am totally new to perl -------------- Sure you can spell it, but do you get it?
|
|
|  |
 |

MalaK_3araby
User
Aug 14, 2002, 11:22 AM
Post #11 of 16
(8880 views)
Shortcut
|
Aaah .. you are so kind. I greatly apprecaite the help. THANK YOU. -------------- Sure you can spell it, but do you get it?
|
|
|  |
 |

roi
User
Sep 11, 2002, 5:20 PM
Post #12 of 16
(8273 views)
Shortcut
|
Hi folks, Read all the post on this thread. I wondered if there is anyway a news ticker system be intergrated into AM. By this I Mean for AM staff themself to write some java news ticker to go along with AM. If possible with the ability for it to only choose headlines from freshly posted articles which are one day old. That be really nice. OR even just by catogry. Thanks! :)
|
|
|  |
 |

canvey
User
Sep 16, 2002, 3:28 AM
Post #13 of 16
(8225 views)
Shortcut
|
For anyone struggling to get this to work - it may be because the stylesheet names have been changed from earlier versions to the newer templates. The stylesheet from 1.05 to 1.21 are totally different/ Will this change of stylesheet names affect anything else in AM?
|
|
|  |
 |

canvey
User
Sep 16, 2002, 6:53 AM
Post #14 of 16
(8219 views)
Shortcut
|
Okay - I am now generating the file - but the data needs to be a slightly different order.... Could anyone help me to get from say <a href="http://www.domain.com/artman/publish/article_0314.shtml">article headline</a> to <a href="http://www.domain.com/artman/publish/article_0314.shtml" target="_blank" value="article headline"> So far I am using the script as, but I haven't quite got the headline & url bits correct. essentially I was trying to make two variables headline & url and insert them into some html text. #!/usr/bin/perl # usage: perl getheadlines.pl cat_index_1.shtml cat_index_n9.shtml > headlines.txt while ($line=<>) { if ($line =~ m|<font class="artname">(.*?)</font>|) { $headline = $line; $url = $line; $line = $1; $headline =~ s|<[^>]*>||g; $url =~ s|<[^>]*>||g; $line = <<END; <a href="$url" target="_blank" value="$headline"> END print "$line\n"; } }
|
|
|  |
 |

canvey
User
Sep 17, 2002, 12:34 PM
Post #15 of 16
(8181 views)
Shortcut
|
Not to worry - my news ticker is working just fine now - and being updated every 15 minutes - maybe a bit of an overkill - but at least the stories will hit the ticker almost as fast as the syndicate
|
|
|  |
 |

canvey
User
Sep 27, 2002, 4:10 PM
Post #16 of 16
(8118 views)
Shortcut
|
I have been asked by a few people if I would share my modified file for grabbing the headlines..... No problem. As usual - neither I nor anyone else will be responsible if your site crashes or your Mother-in-law comes to stay as a direct result of using this script To recap The line that I am extracting from the index file is <font class="artname"><a href="$detail_link$">$art_name$</a></font> (see also Font Class Change below) getheadlines.pl script by using..... #!/usr/bin/perl # usage: perl getheadlines.pl cat_index_1.shtml cat_index_n9.shtml > headlines.txt while (<>) { if (m!<font class="artname"><a href="([^"]+)">([^<]+)</a></font>!) { print qq(<a href="$1" target="_blank" value="$2"> \n); } } Output This produces a file with the data looking like... <a href="http://url/to/article/am_0338.shtml" target="_blank" value="Headline Is Here"> <a href="http://url/to/article/am_0342.shtml" target="_blank" value="Second Headline Is Here"> then repeated for all the other articles shown on that index page. An extra tip: On some of my index pages, I am now using pop-ups (so the link changes), and in fact on some I do not even show the headline - if you find that your $art_name$ link changes or is not even present, and you still want that article to appear in the news ticker - all you need do is to put <!-- <font class="artname"><a href="$detail_link$">$art_name$</a></font> --> In the <!-- templatecell : row --> section of the index template - it will not show on the index page, yet will still get grabbed using the script above. This enables you to alter your index page template whilst still keeping the ticker working. Font Class Change If the script fails - it may be because your font class is wrong in version 1.05 and before of AM, IT used a different stylesheet name for this $art_name$ placeholder. Target The target part is optional, depending upon how you wish for the article to open up. Enjoy.....
|
|
|  |
 | |  |
|