cancel
Showing results for 
Search instead for 
Did you mean: 

Check is region exists

drozes
Champ in-the-making
Champ in-the-making
Hi guys;

I have a template-instance that is used by 3 different page-defination.

Hoping that within my template instance - I can do a manual check if a region is set and has content.

sample.ftl

         
//Here - check if either 'leftContentPiece1' OR 'leftContentPiece2' has content, if so
//output <div class="leftContent">
      <@region id="leftContentPiece1" scope="page"/>   
      <@region id="leftContentPiece2" scope="page"/>   
//Close Div

      <@region id="rightContentPiece1" scope="page"/>
      <@region id="rightContentPiece2" scope="page"/>
      <@region id="rightContentPiece3" scope="page"/>
1 REPLY 1

ddraper
World-Class Innovator
World-Class Innovator
Assuming that you're working with a 4.0.x release then you should be able to do this with a Sub-Component evaluation. Each region will be bound to a component (in a 1-1 mapping) but each Component will be made up of Sub-Components (by default a Component that does not specify Sub-Components will have a Sub-Component generated for it with the id of "default").

If is possible to declare evaluations in the Sub-Component configuration that are run before the Sub-Component is rendered and one option would be for your evaluation to pass if either of the other regions are bound.

The tricky part will be in determining this… but it is possible. If you create a Evaluator that runs as part of your Evaluation then it will have access to the RequestContext and this in turn will contain the ExtensibilityModel which holds the entire output of the page and you will be able to search through this model to find the region and determine whether or not it has content.

Further information on Sub-Component evaluations can be found here: http://blogs.alfresco.com/wp/ddraper/2011/07/29/sub-component-evaluations/

Hopefully this should be enough to get you started.

Regards,
Dave