Regions inside part

Hi!

Is it possible to create regions inside parts?

We have a two column article view (part), where we would like to drag’n’drop parts in the right side column.

Parts XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<part-component>
    <display-name>Artikkelvisning</display-name>
    <config>
        <field-set name="article">
            <label>Artikkel</label>
            <items>
                <input name="article" type="ContentSelector">
                    <label>Artikkel</label>
                    <immutable>false</immutable>
                    <indexed>false</indexed>
                    <occurrences minimum="0" maximum="1"/>
                    <config>
                        <relationship-type>system:reference</relationship-type>
                        <allow-content-type>article</allow-content-type>
                    </config>
                </input>
            </items>
        </field-set>
    </config>
    <regions>
        <region name="article_additionals"/>
    </regions>
</part-component>

Part controller:

function handleGet(req) {
    var component = execute('portal.getComponent');
    [...]
    // 500: components.regions is undefined!
    stk.log(component.regions);
}

Hi Tommy

You can only have regions inside layouts or pages.

I think you can get what you want by creating a layout instead of a part.
Basically the difference between a layout and a part is that a layout can have regions.

See layouts here: https://enonic.com/docs/latest/getting-started/index.html#layouts

Jup, just change you part to a layout!

NB! There is currently a limit that disables placing layouts in layouts. We will remove this soon!

1 Like

That solved it!

Great, thanks!

1 Like

Great! I have been looking for the possibility of layouts in layouts. :smile: Will it be in 6.0, or will it come later?

1 Like

When will that limit be removed?

I would like to have a two column layout. And then within the right column I would like to put a form layout…

The documentation now says: “Layouts cannot be nested.”
http://xp.readthedocs.io/en/stable/developer/site/layout/index.html?highlight=layout

So I guess I will have to make my two column layout a page with two regions, and then make the form as a layout.

But that could mean make a ton of pages.

Lets say you want:

Two columns with form to the right
followed by
Three column with a form in the middle
etc,…

Really what is needed is a new type of region inside part, which only accepts parts.

Then I would simply make a form part, and drag N drop in input parts.

As a workaround I guess I could make a form start part and a form end part. And place whatever input parts between them.

I think I can forget that workaround idea:

The HTML generated by the part must have a single root element.
http://xp.readthedocs.io/en/stable/developer/site/part/index.html#view?highlight=single%20root%20element

Which means I cannot put without in the same part…

I guess I could ignore html validation and do:

form-start-part:

<noop>
<form>
</noop>

form-end-part:

<noop>
</form>
</noop>

I’ll give it a try, but it will probably not work and is ugly as…

Yeah, scratch that workaround.