Mosaic/Layouts: Utilize layouts for any views

I'm using the plone.app.blocks site layout and content layout machinery through Mosaic with lots of tiles.
I'm wondering how to utilize this for any other view, like @@overview-controlpanels, default add/edit forms or custom context independent browser views.
I'm currently missing some parts from the site/content layouts in these views - especially a custom built footer and path bar.

Is there a way to do that?

Yes.

If you are using site layouts, you can enable a site layout globally by settings registry key plone.defaultSiteLayout to point the path of your site layout. It could be /++sitelayout++path/something.html or any traversable path (even a view) in Plone. (There's also plone.defaultAjaxLayout for legacy ajax-load views. The key name is Deco legacy and is defined in plone.app.blocks interfaces.)

When site layouts are enabled, there's dynamic main template override in plone.app.mosaic, which generates main_template from the currently configured site layout (main_template = the master macro called by legacy views). Usually it is enough that the site layout has element with id content for everything to work. Optionally, you can check how data-slots-attributes are used in the default site layouts in plone.app.mosaic (they provide manual hints for where to inject master macro metal slots).

If you just need to enable Mosaic for a single view at time, it's enought that either the view or request provides IBlocksTransformEnabled marker interface and the view generates blocks compatible HTML.

    <!DOCTYPE html>
    <html lang="en" data-layout="./@@page-site-layout">
    <body data-panel="content">
    ...
    </body>
    </html>

In overall, documenting these is one of those things preventing us turning site layouts on by default :slight_smile:

If you are lucky, here might be an example, where the bundled BS3 example is set as the global default site layout http://plonemosaic200rc2.herokuapp.com/Plone/

sounds great!
i'll definetly give it a try today!

I've tried and it works fine so far - thanks for outlining how to do it.

The docs should mention to add this to the projects configure.zcml:

  <include package="plone.app.mosaic" file="sitelayouts-meta.zcml" />
  <include package="plone.app.mosaic" />

Here is a PR, which is needed to properly render control panels:

1 Like

To be more specific, the sitelayouts feature is toggled by ZCML feature flag

 <meta:provides feature="mosaic-sitelayouts" />

which should be defined exist before including plone.appmosaic-package.

The mentioned sitelayouts-meta.zcml exists to make the above possible also directly from buildout's instance (pleon.recipe.zope2instance) part with

zcml =
    plone.app.mosaic-meta:sitelayouts-meta.zcml

And the latter could be appended with built-in BS3 demo site layouts with:

zcml =
    plone.app.mosaic-meta:sitelayouts-meta.zcml
    plone.app.mosaic:sitelayouts-bs3demo.zcml

Unfortunately the pull new docs written during Mephisto sprint is still waiting for review and merge.

Hi, my Question: is there a possibility to remove the Entries that registered by plone.app.mosaic via zcml Directive.

zcml =
    plone.app.mosaic-meta:sitelayouts-meta.zcml

I need this line in my Buidlout to get Access to the Layout-BehaviorField in my DX Editforms. But i don't need the Sitelayout Definitions by plone.app.mosaic, I only want my self created Layouts in the Dropdown Menu.
Illustration for what i mean:


best regards, Jan

Yes.

a) At ZMI, open portal_resources/sitelayout and add a new BTreeFolder with id default, or
b) override site layout directory registration in overrides.zcml

Site layouts use the same plone.resource-framework as Plone theming. There are three different ways to register those directories 1) TTW into portal_resources, 2) adding global filesystem resource directory in buildout (see plone.recipe.zope2instance for details 3) using plone.static-registrations in ZCML. All these can be used at the same time, but 1) overrides 2) and 3), and 2) overrides 3). Because plone.app.mosaic registers the default layouts using 3), all the other options (and also overrides.zcml) can be used to override them.

Thanx, I'll try that.