Search code examples
sonata-adminsymfony-sonata

SonataAdmin - Page/Block rendering


I'm using the SonataAdmin Sandbox to test the CMS functionality, which is so far driving me insane

I have created a site and a test page. Now I'm looking to add content. There is a content_top, content and content_bottom

What I'm looking to do, is to create a 3 column page.

So within the content block list of the page, I have added a basic sonata.block.service.text.

I gave a layout {{ CONTENT }} and a Class of left-col

You can see this in the image below

Now, this is all good and it displays the text from the text.block fine.

I thought that by giving a Class when the block is rendered, it would render the Class field and a HTML/CSS class à la:

<div class="left-col">TEXT BLOCK CONTENT</div>

But alas, this just doesn't seem to happen

Am I right in thinking this Class field is used as the container's HTML css when rendering?

If so, then this is clearly a bug...

Thanks


Solution

  • It's a bit tricky and not well (actually, not at all) documented, but the class setting is actually a CSS class rendered only when the SonataPageBundle's configuration variable is_inline_edition_on is set to true ; which by default is false as the feature has been deprecated.

    The inline edition allowed you to directly access the admin edit page of a block when you were logged in as an admin in the front only by clicking it. To quote the Upgrade document:

    UPGRADE FROM 2.2 to 2.3

    The inline edition (moving block around) from the front website has been deprecated. This has been done for differents reasons:

    • if the html is not valid the javascript can mess up the code.
    • the layout management does not provide a good user experience.

    The code will be remove in further version of PageBundle. if you want the old behavior you need to set to true the is_inline_edition_on key sonata_page configuration.

    The use_streamed_response is deprecated, the option is still available to avoid BC break

    There's no HTML wrapper for a block or a container, if you wish to add one, you should customize the template of your block(s).