Uzelezz Posted October 28, 2010 Share Posted October 28, 2010 Hello Im trying to figure out how to use flat textfiles to my blogproject but cant get the grip on it. It has to be filebased. I can't find any descent tutorial on the web either and it starts really getting on my nerves... 1. How do i save new blogposts in a textfile so they can be easily read? Should i use only one file with append and write all blogposts to it one after another? or save a new textfile for each new blogpost/entry? If so, how do i name them so they don't write over each other accidentally. I need to save (date+writer+title+blogpost). 2. How do i read the files so i can sort them by date/time , latest entry up/oldest entry down? they should appear on my blog startside in the middle one after another. Should i read each blogpost into an array so i can sort them or what? If so how do i do that? 3. I need a list of links connected to each blogpost so when you click link the correct blogpost is shown in the middle of the page same side as the links. the links should be sorted so all posts from oktober is shown under "oktober" and so on... I have ripped half my hair off by now so any general advice how i should do would be appreciated... Quote Link to comment Share on other sites More sharing options...
Jocka Posted October 28, 2010 Share Posted October 28, 2010 I know this isn't really advice but just study the file system: http://www.php.net/manual/en/ref.filesystem.php All the functions are pretty self explanatory. As far as the rest goes, it's mostly just up to you on how you would like your blog to function. I would store blogs in separate files under a folder like blog_files. You could use something like filemtime() to get the date it was modified but if you did that then if u had to go back and edit a page, it would jump to the front. I'd suggest possibly naming the blog text files by blog title and microtime (add blog title just to make it easier to find if there are any complications). Then just get the list of contents in the directory and sort it so that the latest entry (where microtime comes into play) is the first to be viewed. Having a seperate text file holding information such as Author, Date, Blog Title; would come in handy for editing later on. Possibly a different text file per Author holding all of their information? It's really up to you how to handle all that. Just my suggestions for it. Quote Link to comment Share on other sites More sharing options...
litebearer Posted October 28, 2010 Share Posted October 28, 2010 Might also look at http://lukeplant.me.uk/resources/flatfile/ Quote Link to comment Share on other sites More sharing options...
Uzelezz Posted October 29, 2010 Author Share Posted October 29, 2010 Thx for some good advice and good links! I will try to figure it out and see what i can do... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.