Jump to content

Newsticker


kurt.santo
 Share

Recommended Posts

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

I had thought that the CSV grammar made use of quotes to allow it to contain commas in values, so only commas outside of quotes would be counted as a delimiter. (http://en.wikipedia.org/wiki/Comma-separated_values seems to indicate this). So it would be possible.I would still say to go with RSS though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...