[MGNLSTK-586] When using AutogeneratedParagraph main are is not optional but extras area is. Created: 17/Feb/10  Updated: 04/Nov/15  Resolved: 04/Nov/15

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: None
Affects Version/s: 1.3
Fix Version/s: 1.4.x

Type: Improvement Priority: Minor
Reporter: Teresa Miyar Assignee: Ondrej Chytil
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
dependency
depends upon MGNLSTK-675 auto generation of paragraphs: introd... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:

 Description   

Patch

Index: magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java
===================================================================
--- magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java	(revision 31608)
+++ magnolia-module-standard-templating-kit/src/main/java/info/magnolia/module/templatingkit/templates/SingletonParagraphTemplateModel.java	(working copy)
@@ -118,20 +118,22 @@
     }
 
     private void createMainArea(STKTemplate templateDef) {
-        SingletonParagraphMainArea singletonDef = (SingletonParagraphMainArea)templateDef.getMainArea();
-        try {
-            Content mainCollection = ContentUtil.getOrCreateContent(content, "main", ItemType.CONTENTNODE, true);
-            if (!mainCollection.hasContent(SINGLETON_NODE_NAME)) {
-                Content singletonNode = mainCollection.createContent(SINGLETON_NODE_NAME, ItemType.CONTENTNODE);
-                singletonNode.getMetaData().setTemplate(singletonDef.getAutoGeneratedParagraph().getName());
+        if( templateDef.getMainArea() != null && templateDef.getMainArea() instanceof SingletonParagraphMainArea) {
+          SingletonParagraphMainArea singletonDef = (SingletonParagraphMainArea)templateDef.getMainArea();
+          try {
+              Content mainCollection = ContentUtil.getOrCreateContent(content, "main", ItemType.CONTENTNODE, true);
+              if (!mainCollection.hasContent(SINGLETON_NODE_NAME)) {
+                  Content singletonNode = mainCollection.createContent(SINGLETON_NODE_NAME, ItemType.CONTENTNODE);
+                  singletonNode.getMetaData().setTemplate(singletonDef.getAutoGeneratedParagraph().getName());
 
-                setDefaultValues(singletonNode, singletonDef.getAutoGeneratedParagraph().getDefaultValues());
+                  setDefaultValues(singletonNode, singletonDef.getAutoGeneratedParagraph().getDefaultValues());
 
-                mainCollection.save();
-            }
-        } catch (Exception e) {
-            throw new IllegalStateException("Can't create singleton paragraph", e);
-        }
+                  mainCollection.save();
+              }
+          } catch (Exception e) {
+              throw new IllegalStateException("Can't create singleton paragraph", e);
+          }
+        }//end if generate main area
     }
 
     protected void setDefaultValues(Content singletonNode, Map defaultValues)



 Comments   
Comment by Philipp Bärfuss [ 13/Aug/10 ]

the singleton template is called singleton template because it creates a single paragraph in the main area. So I would not start to abuse it. We have to extract the auto generation mechanism to support auto generation of pre-configured paragraphs as it can be used in many other cases.

Comment by Michael Mühlebach [ 04/Nov/15 ]

Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes.
Thanks for taking the time to raise this issue. As you are no doubt aware this issue has been on our backlog for some time now with very little movement.
I'm going to close this to set expectations so the issue doesn't stay open for years with few updates. If the issue is still relevant please feel free to reopen it or create a new issue.

Generated at Mon Feb 12 07:28:28 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.