Jump to content

Newsticker


kurt.santo

Recommended Posts

How could you implement a news ticker in a designated bar on a web page, which when clicked upon opens the page with the relevant story? I did not know that it is possible to do that, but was told it is (unfortunately the guy did not know how to do that)... Any ideas appreciated.Kurt

Link to comment
Share on other sites

Well, the idea would be to have PHP dynamically put the list of news and links to the news article (retrieved from a database) into a JS file and then make Javascript write the news titles into the document.

Link to comment
Share on other sites

Haved you looked into Yahoo pipes? You can implement a pipes feed through AJAX/JSON and dump the pipe feed object into any element you want formatted pretty much any way you want with css. It's no good if your page is https, but it could be a solution for you.

Link to comment
Share on other sites

Would it also be possible to have the newheadline taken from a normal text file as opposed to database? This is a very smallish website and I do not think there is really a need for a database (unless we really need it to accomplish what I am after).Will look into Yahoo pipes, never heard about them before. So, will have a throrough read...Cheers,Kurt

Link to comment
Share on other sites

Err... oh I see, you are yet to choose. Well - (this is if you want to store multiple news items which I suggest)CSV = Comma Seperated Values e.g.

News Story 1, 12/02/2008, This is the first news story. In CSV files they cannot contain commas or else an extra "column" will be created. Another option is tab separated values (tabs instead of commas), <link goes here>News Story 2, 1/2/06, This is a very old story (as you can see from the date)., <link goes here>

XML = eXtensible Markup Language - I would suggest this as it is easy to parse and you can make your news stories into a RSS feed (a form of XML) e.g. view source of http://w3schools.invisionzone.com/index.ph...rssout&id=3JSON = JavaScript Object Notation - ignore the JS, JSON can be parsed in many languages .e.g.

[	{		"title" : "News Story 1",		"date" : "12/02/2008",		"description": "This is a JSON file. Simple, but XML is still more advantageous. JSON is good for its native support in JavaScript.",		"link" : "<link goes here>"	},	{		"title" : "News Story 2",		"date" : "1/2/06",		"description": "This is a very old story (as you can see from the date).",		"link" : "<link goes here>"	}]

So first, pick - which one? I would suggest XML (RSS), because then people can view your news with RSS parsers, and you can still easily parse it to your page.

Link to comment
Share on other sites

I would suggest XML (RSS), because then people can view your news with RSS parsers, and you can still easily parse it to your page.
I definitely cannot use CSV with comma separated fields as there will be many commas in the news stories. So the only options are then tab separated values, XML or JSON. Would like to take your suggestion on board and use XML, but where do I start? I would have to learn how to create an XML file (never done before), get the headline of the latest story into the code for a Javascript ticker (which I have never done either). Seem quite a lot to cope with. Do you know a good tutorial to do exactly this? This would be great! Always eager to do new stuf, just sometimes struggling to get going...Kurt - The one with little brains....
Link to comment
Share on other sites

To create /edit a RSS file you can just open it in a text editor (Notepad will do). Look at the structure of the example for what a RSS file should look like, or check out the W3Schools tutorial ( http://www.w3schools.com/rss/default.asp ). Then, you can use the XML DOM to parse the XML to the page. Read http://www.quirksmode.org/dom/importxml.html for that. With this method you can even have the news change periodically without the user refreshing the page. Also, as aforementioned RSS viewers can read the file so people can view news without going to the site.

Link to comment
Share on other sites

To create /edit a RSS file you can just open it in a text editor (Notepad will do). Look at the structure of the example for what a RSS file should look like, or check out the W3Schools tutorial ( http://www.w3schools.com/rss/default.asp ). Then, you can use the XML DOM to parse the XML to the page. Read http://www.quirksmode.org/dom/importxml.html for that. With this method you can even have the news change periodically without the user refreshing the page. Also, as aforementioned RSS viewers can read the file so people can view news without going to the site.
Cheers! Will have a proper read and try on weekend...Kurt
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...