1

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.

  • 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 Dec 23 '13 at 06:50
  • http://symfony.com/doc/current/cmf/book/database_layer.html – Wouter J Dec 23 '13 at 08:48
  • 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 Dec 23 '13 at 12:06
  • Would "write custom Blocks" be the 4. and only answer? – Maximilian Berghoff Dec 23 '13 at 13:47

1 Answers1

5

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.

  • That Sound good, but when i create own documenta what is the sense of the cmf? Sorry for that question. By the help of symfony and the sonata bundles i can easily write backend and frontend. Is it "just" the power of the routing? Ok i do not need to write so much own block types. – Maximilian Berghoff Dec 23 '13 at 22:17
  • I expected that the content bundles could be parts of own documents. I thought to create own documents as thin wrapper around several blocks, only to classify this collection. I thought to have a "block builder" like the form builder in symfony, to map units of content into its blocks. Is that idea so far away or only nonsense? – Maximilian Berghoff Dec 23 '13 at 22:24
  • Maybe https://github.com/dbu/conference-tutorial/pulls could give you some ideas. The point of the CMF is mainly to provide you with structure and handling things like routing. The actual documents are the easiest thing. For brievity, my examples extend the cmf documents but that really is a matter of taste. – dbu Dec 25 '13 at 09:48
  • Regarding blocks: Some systems like the java based Magnolia CMS create pages out of blocks of content, defining what area accepts what type of children. This is a very rigid and structured way to do a CMS. It has its merits, enforcing design standards as there is no uncontrollable WYSIWYG at all. For the CMF, we do not provide anything explicit (yet) so mainly the admin side will take quite some effort. Rendering will already be totally doable with the BlockBundle. – dbu Dec 25 '13 at 09:51