Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one structure a CMS?

So I am making a CMS, a gallery script via Object Oriented PHP. Anyways, the problem is now that I have the basic layout for the objects and such to the point where I need to start putting together, I am stumped how to do this.

What I have is essentially a Navigation, Data, Gallery, and Module class. Module stands for pages, categories, et cetera. The problem is that Gallery outputs the images, module gives the data for the pages, navigation creates the (you guess it) navigation. You get the picture.

On the index page, I end up doing essentially this (this WILL change, but it is illustrative for how I was starting to set it up):

$navigation = new Navigation();
$navigation->top();

$page = new Module();
$page->basicPage($_GET['m']);

The basicPage() does a few things, but primarily this is the issue:

$gallery = new Gallery();
$gallery->setGallery($id);
$gallery->thumbGallery();

So on so forth.

The problem arises in that if I call basicPage(), the designer or whoever has very little control over the choices. As you saw, it is thumbGallery, and that doesn't allow full images, and it doesn't even let you set the size of the thumbnails (which I do let them do, only if they can call that function them self though).

So I thought of a few solutions to the problem. I don't have these basic pages, but I have the designers build out templates much like wordpress. I dislike this solution, because it makes the design process complicated, albeit thorough. I don't want to make it so that everything is controlled, and is one way. Of course you can "display: none" to elements as the designer and a few other tricks, but I want them to have the ability to do a lot of things, without the complicated way that Wordpress does it.

My question is how do I strike the balance between simple and flexibility?

Any help, even ideas are appreciated. Thanks.

EDIT: I forgot to mention. The problem is from just having the index have all of this data is otherwise I will have to do a lot of if/else and such, and I really didn't want to make this a procedural program, just one you can essentially just plop stuff down and we're good. See, module stands for both gallery and page. Most pages will not have images attached to it, and the categories will have images, but not always text. It will cause an error if I call thumbGallery and it is just an informational page, and if I call an informational page and it is a category, it will not show the images (to avoid the error). I could, and have started to build it together in what is called basic page,but the problem like I noted before is that it restricts how much freedom the designer has without having to mess with php, and most designers are pretty dumb when it comes to php, unfortunately. Espectially OOP (no offense. I am a designer too, but I happen too program).

like image 648
Luke James Emery Avatar asked Nov 13 '22 21:11

Luke James Emery


1 Answers

Without seeing the rest of your code it's difficult to know the best solution considering what you already have. I've developed my own custom CMS Application Frameworks from scratch for the past 9 years, and I'd be glad to give you some tips.

I'm assuming you're storing all the CMS content in a database. Storing the configuration for the gallery settings in the database might be a possible solution. In theory you should have different views (following the MVC pattern) for displaying the gallery in different ways. A listing view for showing multiple image thumbnails, one for showing a single image, plus a view to list categories perhaps.

So, in the database you could define that page X should show the thumbnail view instead of a category view.

Not sure if that's a solution to the problem you have, but that's a very simplistic example of how I've done it in my CMS's in the past.

like image 91
Percy Avatar answered Dec 11 '22 01:12

Percy