Jump to content

Flatfilebased blog


Uzelezz

Recommended Posts

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...

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.