如何构建 CMS?
所以我正在制作一个 CMS,一个通过面向对象 PHP 的画廊脚本。不管怎样,现在的问题是我已经有了对象的基本布局,以至于我需要开始组合,我很困惑如何做到这一点。
我所拥有的本质上是一个导航、数据、图库和模块类。模块代表页面、类别等。问题是图库输出图像,模块提供页面数据,导航创建(你猜对了)导航。你明白了。
在索引页上,我最终基本上做了这个(这会改变,但它说明了我如何开始设置它):
$navigation = new Navigation();
$navigation->top();
$page = new Module();
$page->basicPage($_GET['m']);
basicPage() 做了一些事情,但主要是这个问题:
$gallery = new Gallery();
$gallery->setGallery($id);
$gallery->thumbGallery();
等等四。
问题在于,如果我调用 basicPage(),设计者或任何人对选择的控制权很小。正如你所看到的,它是thumbGallery,它不允许完整图像,它甚至不允许你设置缩略图的大小(我确实让他们这样做,但前提是他们可以自己调用该函数) 。
于是我想了一些解决问题的办法。我没有这些基本页面,但我让设计师构建了类似于 WordPress 的模板。我不喜欢这个解决方案,因为它使设计过程变得复杂,尽管很彻底。我不想让一切都受到控制,而且是一种方式。当然,您可以像设计师一样对元素“显示:无”以及其他一些技巧,但我希望它们能够做很多事情,而不需要像 WordPress 那样复杂的方式。
我的问题是如何在简单和灵活性之间取得平衡?
任何帮助,甚至想法都值得赞赏。谢谢。
编辑:我忘了提及。问题是仅仅让索引拥有所有这些数据,否则我将不得不做很多 if/else 之类的事情,而且我真的不想让它成为一个程序程序,只是一个你基本上可以简单地扑通扑通的程序把东西放下,我们就很好了。看,模块代表画廊和页面。大多数页面不会附加图像,并且类别将具有图像,但并不总是文本。如果我调用thumbGallery并且它只是一个信息页面,它将导致错误,如果我调用一个信息页面并且它是一个类别,它将不会显示图像(以避免错误)。我可以,并且已经开始在所谓的基本页面中一起构建它,但是像我之前提到的问题是,它限制了设计师拥有多少自由度,而不必弄乱 php,而且大多数设计师在遇到这种情况时都非常愚蠢不幸的是,到php。特别是OOP(无意冒犯。我也是一名设计师,但我碰巧也是编程)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不查看其余代码,就很难知道考虑到您已有的最佳解决方案。在过去的 9 年里,我从头开始开发了自己的定制 CMS 应用程序框架,我很高兴为您提供一些提示。
我假设您将所有 CMS 内容存储在数据库中。将图库设置的配置存储在数据库中可能是一种可能的解决方案。理论上,您应该有不同的视图(遵循 MVC 模式)以不同的方式显示图库。一个用于显示多个图像缩略图的列表视图,一个用于显示单个图像的列表视图,也许还有一个用于列出类别的视图。
因此,在数据库中,您可以定义页面 X 应显示缩略图视图而不是类别视图。
不确定这是否能解决您遇到的问题,但这是我过去在 CMS 中如何完成此操作的一个非常简单的示例。
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.