1
votes

I've red so much about the symfony cmf. Red the whole docu and the cookbook too. Now i wanna create my first cms application. It is very easy to get a starting kit based on the sandbox. This works. I am able to create and manage all documents from all bundles. I am able to setup the rendering. But how do i work with custom documents which can contain some parts of the cmf?

For example i wanna write a article bundle for a reporter to manage its articles. These articles can contain text, title, some images or other documents like pdf. They are referred to groups, which can be documents too, cause i want to give them some text, title and a image.

This should be a typical task for a cms and i want to solve it with the symfony cmf. But what is the right way?

  1. Easiest way: Use the base documents, but this would mean i have to say the cms admin to create some blocks and combine them, or to create a StaticContent document and refer some imageBlocks. The Controller for the rendering of the frontend view will work on its own only by setting some options in the config.

  2. Create a ArticleDocument which can inherit from the AbstractBlock or from the StaticContent and add some more informations i would need. Here i need to write an own Controller and set hin in the conifg. By this i can offer a single "ArticleDocument item" in the backend to manage and no list of independent base documents, which could be confusing for an cms admin who only wants to manage its articles

  3. Create an independent ArticleDocument based on the phpcr, maybe with some properties which will be needed for the menue and routing. But then i would write a complete new controller and map "my" informations to some cmf blocks or content documents to render them.

A part of this question is based on my lack of experience in working with document. I need to get a better "document view" instead of my "RDMS-view" on Objects. But i wanna learn it by using the symfony cmf.

Are there some examples which build custom Documents? The Sandbox is cool but only shows the frontend work in DemoBundle.

1
I think i have found an answer in the BlogBundle. Thought: i do not need a Blog function at the moment. Causes by this thinking i missed to look through this code. But there are lots of answers to my questions. The answer is: 3 Create Documents based on the PHPCR and write a custom controller (as a Service) to render its data. But the only dependency to the cmf, that i found was the BlockService for some tags and the reference to the route. Is there an example that uses the the core content bundles like the ContentBundle oder the BlockBundle?Maximilian Berghoff
Ok, that's a good example for working with doctrine's phpcr-odm implementation. It helps how to generade CRUD-Actions with it. But from this point of view it is completely independent from the symfony-cmf. I can do it as shown in the example, write an own controller with an own template and it would work.Maximilian Berghoff
Would "write custom Blocks" be the 4. and only answer?Maximilian Berghoff

1 Answers

5
votes

In general I find that creating your own models and admin classes is so easy that I recommend to define your own rather than extend from the core ones.

As for using blocks vs. just using properties or more specific child documents. Blocks are all about reusability, being able to be administered more independently and independent caching. If you need any of these use a block, otherwise it might be easier to just create a custom document (hierarchy).

Now when it comes to properties vs. children. As there is no overhead with empty properties, its possible to keep the structures as flat as you want by just adding everything as a property. A child is useful if you want to potentially manage things a bit more separately or create units of content. For example if you have an image and some meta data for that image, its logical to use a child to store the binary and the meta data because if you want to move or delete the image, you want to delete them all together.