In Search of a Particular Tutorial
Posted 17 April 2006 - 05:31 PM
I'm currently trying to do several things at once: Build a webpage (something I'm not too bad at, at least from a design perspective) and learn PHP (something I've just started at, and am not at all good with yet.) My design for the site includes a newspost/blog on the front page, but every open-source PHP blog I've come across (even the ones that claim to be simple) have too much excess on them. All I'm really looking for is a way to organize bits of news by date of creation and post a certain number to the front page, with an archive page for the rest.
Since it's for my personal site, I can add complexity to it as I see fit, and so this strikes me as a great opportunity to learn some 'real world' PHP at a level slightly above most beginner tutorials. Unfortunately, I can't find any tutorials or guides on how to build a very basic blog from the ground up, and I'm not good enough at PHP yet to disassemble other blogging code and see how it's done.
What I need, therefore, is a good 'DIY' blog tutorial that others have either found or made (I couldn't find one in the tutorial section here, sadly.) Barring that, I'd be happy with a suggestion or two on how I should start thinking the design through. I figure that best practice is to write entries, timestamps, etc. to a database, just as everything else is database-driven these days; beyond that, I really don't have any requirements.
Any advice and help is much appreciated. Thanks a lot!
Posted 17 April 2006 - 06:54 PM
what information do you want for each blog entry? you need to think about content, such as the title, main text, date/time, user id (if youre not the only person posting), pictures, etc. the blog i use only has these 5 fields in my MySQL database:
id - the record key
public - this is set to y or n, and determines whether it's just a saved entry or whether it has been published.
date - a timestamp of when the blog entry was created
title - simple title for the blog entry
entry - the text that makes up the main blog entry.
of course, you could also use a plain text file or even a XML file if you know much about them instead of a mysql db. the principles are very similar with each. in some ways too, using a text file or a XML-type file would be easier than also having to learn MySQL.
once you've planned how youre going to store the data, the whole process of putting the blog together is fairly straightforward. if you're using MySQL, then ANY mysql tutorial will get you the basics you need, including using SELECT/ORDER BY (for getting blog records to be displayed), INSERT (for creating new entries) and UPDATE (for editing existing entries). you don't need to go any further than that for now.
once you've got the grasp of that, all you need to do (in HTML) is design a 'container' where a single blog entry will go. wrap it in a PHP 'while' loop to read all of your SELECTed entries from the database, using the 'echo' function to display the information you've read from a blog entry.
ok, i've not gone as far as posting the code for you, but if you can get a clear idea of what you need and how it should look, the amount of PHP you need to get the whole job done is very minimal.
hope that helps a bit,
edit: i do have bits and bobs of a simple blog script i use (have a look at it working here [a href=\"http://www.crashandburn.co.uk/blog.php\" target=\"_blank\"]http://www.crashandburn.co.uk/blog.php[/a] and here [a href=\"http://www.thedinnertimes.com/columns/\" target=\"_blank\"]http://www.thedinnertimes.com/columns/[/a] ). youre welcome to have the scripts to have a look although for the sake of getting to grips with things and figuring it out, youre better have a bash at it yourself. if you want them tho, just drop me a PM.
I say old chap, that is rather amusing!
Posted 18 April 2006 - 12:30 PM
My one concern about using XML to store blog data is the slow increase in read time: As I append blocks of data to the XML file, the most recent entry (and thus the entry called first for display) is the last major element in the file. The second entry will be the second-to-last, and so on and so forth. Thus any script that pulls data from the XML file by timestamp will have to go all the way to the end of the file to get it -- very slow. It's only text, so it's not a huge problem, but is there a clever way to either (a) insert entries into the 'top' of the XML file, so that the most recent items are accessed first by a simple search? or (b) 'jump' quickly to an element with a particular value or attribute value? (If there isn't, the easiest thing to do be to create individual XML files for a particular period of time, say a year, to keep search times per file low.)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users