I am trying to figure out a more efficienct structure for my website and how it handles files and contents. I am trying very hard to separate all my html and php and although it is going well, I have so many files it’s getting hard to keep track of them.
One idea I had was to no longer have a page for each page, but rather one page which calls the components requested, giving the illusion of many individual pages while making the number of pages to alter (if I have to) reduced to one.
So I have the basename function which can tell me the page requested. Is there any way to have a file catch all page requests to that folder?
Like if a file was named "*" in the directory "/folders/pages/" and someone requested "/folders/pages/home.php" then it would run the "*" file? That is the only way I can think of having one file without using $_GET’s and some mod rewrites? Any other suggestions welcomed!
I don’t really understand your question, but I haven’t had my coffee yet.
Anyway, I see you’re trying to implement the beautiful ‘business seperated from presentation’ idea. There are a lot of things out there that will help you with this, one of those is a framework. Most frameworks implement the MVC structure – Model-View-Controller. Basically, it seperates your Model (data requests, etc), your Controllers (makes requests to your models and hands data to your views) and your Views (presentation).
I suggest you check out CodeIgniter (very low learning curve) and if you get any problems I’d be glad to help.
As to your original problem, could you try and explain it more (I know you’ve explained enough, but I’m feeling watered-down today).
I have never used a framework, but it keeps coming up so I will have to look into it. I know that I can achieve what I want with rewrites in my htaccess file, and after some extensive googling I think this is the only way. I wanted a "catch all" page which would process which page was requested and call the appropriate content, provided it existed. I was thinking about using the 404 error page in someway?
Could you not pass a value via the URL and on a, say, index page use that parameter to call the content into your index page?
I don’t really want to use GET variables, but as I said before, it is either that or doing some tricky things with code ignitor. Thanks for the link btw, it looks like a door into a whole new PHP world, but I am not sure I want to do it now even though it will make this project easier. It looks very OOP-like?
I have never looked at OOP and everytime I do it seems illogical, but I have been learning web-programming for a year now so I should probably start the OOP path! Do you have any good starting points for learning OOP (from no prior experience)?
OOP is definitely something you have to learn, because most programming languages use it. And, yes, CI uses OOP, but it makes it less of a learning curve when used with the framework.
Sure, the logic of OOP is easy(ish) to comprehend. My problem was taking that logic and applying it to a problem. I just couldn’t get my head around it..
I’ll find you some resources tomorrow, because I need to go to bed now! 😛
Thanks mate. I still have a lot to learn, and with only weekends to do anything significant, it could be a long haul, but it’s gotta be done!