Now, as the more experienced of you understand, the page title, header and footer (and why not even the content) is decided upon the address (ie. ?page=news).
Okay, instead of using this system, I'd want the title, header, content and footer to be fetched from a database. How would I do that?
The reason why is because I can't write a title that consists of several words, or contain non-english letters. Anyways, since this is for online newspaper, it would be more handy if the articles were stored in a database.
So, is there anyone who could help me with this? I would really appreciate it if anyone could guide me through this! Thanks!
Thanks PrObLeM, but that doesen't seem to be what I'm looking for...
What I would want is a template, where the header and footer are linked from other files, and the main content changes upon the address (ie. index.php?article=031011). The articles actually wouldn't need to be in a SQL database; they could be in simple html/text files (just the text and some easy tags as <p>, <h1>, <h2> and so on.
So, if the visitor selects a link (let's say index.php?article=031011), nothing else on the page would change, except for the content (that would be taken from the external file (ie. articles/031011.html). I know there are ways of doing this where you need to define all the pages separately, but that's too much work, since this is going to be a online newspaper with lots of articles.
However, it would be cool if the articles could be divided into different categories by year, month and day, but that's not a must.
And, when the user would click on this link, the title would also change so that it would go from ie. "News" to "News | Bla bla bla". So in other words, I would need to be able to define the title of the page, and it would be nice if I could do that inside the external file. Is this possible, and if so, how could I do it? Please, I'd really need some help! I would be most grateful if someone could post some PHP code for me, and try to explain it to me!
Edit: And yes, I would want to add one more thing: There should be a default source page in the main content area if someone only types index.php (well, quite naturally, since that's where the "headlines" would be, if it's a news page that is). If the user however tries to access a page that doesen't exist, there should also be a 404 page.
Okay, since the new post was deleted - which a completly understand - I will have to refrase myself. And to missing-score: yes, I have permission to put five MySQL databases on my account. I would, however, prefer external files, but if you find this not such a good idea, please let me know!
So, to clear things up, this is what I'd need for my PHP template:
Header, footer and any other extras should be included from external files.
The main content area should change upon the address. Practically, what I mean is, that if you would write index.php?article=031120 in the address bar, the main content area would reload with the article (from eg. articles/031120.php). I know this can be done by predefining every single page in index.php, but that would take too much time, since there would be so many pages.
In the article file (eg. 031120.php), I should be able to define the title, so that it would appear in the browsers title bar.
When only index.php (without eg. ?article=xxxxxx) is entered, there should be a default page.
If the visitor tries to access an article that doesen't exist, or have typed the name wrong, a 404 page should appear instead.
So this is everything I would need in a nutshell. I really hope there's someone out there who could help me out, 'cause I've searched everywhere on the Internet without any results.
The load_page() functions checks the article information (page.php?article=2) and attempts to load the article. If the article is not found, it returns '404', which is the notfound error. If mysql query fails, it returns '500' which is internal server error, and returns '200' if there is no article specified, meaning 'ok'.
The numbers are used merely to relate it more to the general HTTP error messages.
After the function is finished, the function is called and the return value is tested. If it is not true, then it checks for any one of the error numbers and displays the page respectively.
Yes, the article id will always be the same as the filename. But, what would I need for the visitor to get an error message if he/she tries to acces a page that doesen't exist? And how about the default page?
I hope I'm not making too much of a fuzz about this, but I really need your help, since you clearly know these kinds of stuff! Also, would it in any way be possible to define the title of the external article (in the article itself), so that it would appear in the title bar (eg. My website > Articles > Bla bla bla bla...)?
Before knowing how your articles are formatted (where the title is ect) i cant say how you could show the title. In a database the title could be stored in another field, but as you wish to use flat-file, could i see what the article pages will look like?
Thanks for that missing-score! The external files wouldn't be anything special, raw text mainly but with some tags like <p>'s <h1...2...3>'s and stuff like that. The files would in other words just contain the article itself, and I would then format them through CSS. Example: