4

In our implementation there is one Main Region, where previously items where render like it is on following image

enter image description here

During implementation of certain View, we identify that there should be another region, but in that case, we had issues with html. So we decided to use only Main region and to render all items there. But some items should have its own div while others should remain in the main.

I made following code, and it works ok enter image description here

I can move some logic to the Controller, but I would like to know is there any other solution.

In the case of region, we can pass information such as using of @Html.DxaRegions(exclude: "name of the region")

enter image description here

So is there any other solution?

3

I think what you want to do is create an AssetGroup region, so for that you should create a region view:

@model RegionModel
<div class="menuAssetsGroup" @Html.DxaRegionMarkup()>
    @Html.DxaEntities()
</div>

Don't change the Main region view, the GeneralPage view will automatically be adding your AssetGroup region when there is content on the page in that region.

To get the content into the AssetGroup region, make sure you configure your Asset Component Template to be in the AssetGroup region by supplying this new region name in the Component Template metadata, as described here http://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v2/GUID-8714ED2D-4F98-4433-80DD-6A4FE2E6EC64

In case you need your AssetGroup region to be in a fixed place in the page layout (not depending on Component Presentation order), you can change the GeneralPage view and add your new region by calling:

@Html.DxaRegion("AssetGroup")

And making sure to exclude it from all the other @Html.DxaRegion calls.

Please note it would be advised to make all these changes in a separate module, rather than changing the core views. See these two blog posts for some more information on how to create modules in DXA:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.