Jump to content

Basic CMS working, but question with regard to efficiency


son

Recommended Posts

I have build basic options for user to update the content on their websites and think now it the time to build one global version that I can use again and again without me spending hours each time to do a new system... This will also be better to update when needed. The parts I have so far are great and with some mod rewrite all also very URL-friendly. However, I have a theoretical question that I find hard to solve with my pen and paper here. Maybe some of you can share their experience when you build systems like this... As for the websites in general: Thee homepage is a bit different from the rest and cannot be deleted. There are some other pages that all fit the same design, those can be deleted and also pages can be added. There is also usually a gallery page (or several). My main question: do I physically create one page that brings in content with logic for all those different bits or do I do one for homepage, one for the pages that can be delete and created (all can be updated any time) and one for gallery? Where lies the balance in between avoiding redundancy/creating too many similar web pages and slowing the web page down due to too many logical checks? Any experience and/or help appreciated! As I said I am pretty ok for technical bits, I only need some theoretical backing (or maybe you know how to run tests to measure what would be best?)...Thanks,Son

Link to comment
Share on other sites

An object-oriented design would make sense, create a Page class that you can use to represent any page in the site, and extend the class for specific types of pages or just create instances for each page. Then you can have any number of other pages using the classes, and if you need to update things you can update the class files that all pages use, or the individual pages that use the classes.

Link to comment
Share on other sites

Thanks. That is very helpful. I will create a homepage, one for the ones you can update/delete and another one for the gallery... I am not to verses in object-oriented programming, but have great includes for header and footer that include all the general stuff and might just need some tweaking here and there. Would it be better to learn object-oriented programming? Till now, I have not used this at all as there was no need... Son

Link to comment
Share on other sites

It's not about a need, it's about best practices. You can do it without using classes, but I think you'll find them easier to maintain and it will also be easier to write new code that uses the classes. It may be difficult to learn certain things at first, but it's worth learning. Read through some of the topics here: http://www.php.net/m...nguage.oop5.php Start at the beginning and go from there. There are several interesting things you can do or use classes for, like autoloading, visibility, inheritance, static classes, traits, etc. Check the section about patterns for some common design patterns that people use, like the factory pattern. Once you start with classes you'll start noticing any number of situations that would work better if you used a class. Static classes in particular are very useful, you can use a static class to replace some global thing like a database connection or config information without needing to declare anything as global.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...