kurt.santo Posted February 8, 2008 Share Posted February 8, 2008 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 More sharing options...
Ingolme Posted February 8, 2008 Share Posted February 8, 2008 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 More sharing options...
LittleSam Posted February 8, 2008 Share Posted February 8, 2008 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 More sharing options...
kurt.santo Posted February 11, 2008 Author Share Posted February 11, 2008 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 More sharing options...
Ingolme Posted February 11, 2008 Share Posted February 11, 2008 You can obtain information from a text file using the PHP file_get_contents() function. Link to comment Share on other sites More sharing options...
kurt.santo Posted February 11, 2008 Author Share Posted February 11, 2008 You can obtain information from a text file using the PHP file_get_contents() function.Ingolme,with get_file_contents would it be able to get only the headline? Also, when Javascript generates the news-ticker: is it possible to click on it in order to get to full story? Kurt Link to comment Share on other sites More sharing options...
Synook Posted February 11, 2008 Share Posted February 11, 2008 Well, where are you getting this news data from? Link to comment Share on other sites More sharing options...
kurt.santo Posted February 11, 2008 Author Share Posted February 11, 2008 Well, where are you getting this news data from?Well, just want to upload a file with newstory including heading (which always overwrites the previous one) and then the rest should be taken care of by what I am going to set up.... Kurt Link to comment Share on other sites More sharing options...
Synook Posted February 13, 2008 Share Posted February 13, 2008 Yes, but what format is the file with the news story in? XML? CSV? JSON? Link to comment Share on other sites More sharing options...
kurt.santo Posted February 13, 2008 Author Share Posted February 13, 2008 Yes, but what format is the file with the news story in? XML? CSV? JSON?Sorry, mate. Guess it would be CSV as I have not used XML and JSON (what is that?) before. Or do you think this is not a good option?Kurt Link to comment Share on other sites More sharing options...
Synook Posted February 13, 2008 Share Posted February 13, 2008 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 More sharing options...
kurt.santo Posted February 13, 2008 Author Share Posted February 13, 2008 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 More sharing options...
Synook Posted February 14, 2008 Share Posted February 14, 2008 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 More sharing options...
kurt.santo Posted February 14, 2008 Author Share Posted February 14, 2008 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 More sharing options...
AElliott Posted February 14, 2008 Share Posted February 14, 2008 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 More sharing options...
justsomeguy Posted February 14, 2008 Share Posted February 14, 2008 That's right, the CSV grammar includes quotes and slashes to escape quotes if necessary. You can store any data in a CSV file, you aren't limited with what you can store based on the delimiter. Link to comment Share on other sites More sharing options...
Synook Posted February 15, 2008 Share Posted February 15, 2008 I stand corrected. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.