cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to assign multiple components to the same region?

sam1980
Champ in-the-making
Champ in-the-making
Hi.

I am new to Surf and the problem stated might be the expected and correct behavior, but for me it is unexpected. So I need some confirmation of my observations as I can't find any documentation on the subject. Is it not possible to assign multiple components to the same region on a page?

I.E
<components>
    <component>
      <region-id>main</region-id>
      <url>/static-modules/services</url> 
      <scope>page</scope>
    </component>
    <component>
      <region-id>main</region-id>
      <url>/tabbed-navigation-interface/highlights</url>
      <scope>page</scope>
    </component>
</components>

The rendering process seem only to render the last of registered components in the main-region, which is kind of odd and not very flexible. I'd expect them to be rendered sequentially in the order they are registered.

Grateful for any feedback on this matter.
3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator
Hi,

Unfortunately it's not possible to bind more than one Component to a Region in Spring Surf as there is a direct 1-1 mapping.  The version of Spring Surf that you will have bundled with Alfresco 3.4.d does not provide any alternatives, however in the version that will be included with Alfresco 4.0 we have introduced the concept of Sub-Components to solve this problem.

I appreciate that this is not much help to you now, but in the future you will be able to create an Extension Module that extends a Component to add, remove and modify Sub-Components  (see http://blogs.alfresco.com/wp/ddraper/2011/07/22/how-to-add-content-to-an-alfresco-share-page/).

A Surf Component is uniquely identified by the combination of the region-id, source-id and scope (which is why it's not possible to bind multiple Components to a single Region). In the Component configuration you've included Surf has created a Component object using the region-id, source-id and scope and then immediately overridden it with the second Component definition (because it has the *same* region-id, source-id and scope)…. this is why you're only seeing the last Component (because in Surf terms there is only one).

If you provide some more information on what you're attempting to achieve then I will hopefully be able to help you workaround the problem for v3.4.d

Regards,
Dave

sam1980
Champ in-the-making
Champ in-the-making
Thanks for your reply. It was really helpful.

What I'm essentially trying to achieve is to keep the template structure really simple as well as flexible:

<#include "/common/layout.ftl"/>
<@layout>  
  <div class="main">
    <div class="row">
      <div class="eightcol">
        <@region id="main" scope="page"/>       
      </div>
      <div class="fourcol last">
        <@region id="contextual" scope="page"/>
      </div>
    </div>
  </div>
</@>

All my website's pages are in a two column configuration, with a region "main" and a region "contextual" representing each column. The only difference between pages is that each page registers a different set of components to either the main or contextual region. But not being able to put several components into one region ruins this approach. As of now I guess I have to define main_1, main_2, main_3 and so on in order to have large enough set of regions to work with.

ddraper
World-Class Innovator
World-Class Innovator
This is exactly how the user and site dashboards have been implemented in Alfresco Share. Depending upon the layout you select there will be varying "grids" of regions and many won't be populated (this is why it's only possible to add 5 dashlets per column in a dashboard). If a region is "unbounded" you will still see it in the page source as an empty <div> element.

This is a limitation of the older versions of Spring Surf but things have definitely improved in the latest version and we're continuing to make this better and easier to do layouts.

Regards,
Dave