cancel
Showing results for 
Search instead for 
Did you mean: 

Create content with pairs of data type <content>

kooroshv
Champ in-the-making
Champ in-the-making
Hi,
  I a newbie to Alfresco. I have read the wiki on 'Data Dictionary Guide' and have Alfresco installed and working. Now as part of evaluating the product, I am trying to create a content type that would allow a user to create a Question and Answer type content. In another words, when the user goes to create a content, he would get a form that would look as follow:

============================
Product: <Pick list of products>

Question: <textarea>

Answer: <textarea>
============================

So what I did was to create a custom model as follows:

   <types>
      <type name="custom:QA">
         <title>Q-A</title>
         <parent>cm:cmobject</parent>
         <properties>
            <property name="custom:Question">
               <title>Question</title>
               <type>d:content</type>
            </property>
            <property name="custom:Answer">
               <title>Answer</title>
               <type>d:content</type>
            </property>
            <property name="custom:QA_ID">
               <title>Article QA ID</title>
               <type>d:text</type>
            </property>
      </properties>
         <mandatory-aspects>
            <aspect>cm:versionable</aspect>
         </mandatory-aspects>
      </type>

  The above model passes ModelTest. I also updated the web-client-config-custom.xml and added it 'Content Wizards' section. However, when I start up Alfresco, I get the following message in the log file:

Failed to add 'custom:QA' to the list of content types as the type is not a subtype of cm:content.

This means I can't create a content which is not subtyped by cm:content if I want to user 'Content Wizards'. Then does this mean, I should create my own 'QA Wizard'? Could someone suggest what is best practice here, any pointers is appreciated  :?:
3 REPLIES 3

norgan
Champ in-the-making
Champ in-the-making
Hmm, three ways come to mind currently

1) You could create your own contenttype derived from cmSmiley Surprisedbject - plus your own set of edit/display forms.
2) You could define a folder with the fields "question" and "answer" and a behaviour "on update, generate "QandA.html" inside that folder.
3) You define your own contenttype derived from cm:content, acting same as under "2", but extend the "content creation wizard" to generate the content after filling out the metadata with a "runAs" function built in. Last, store the content in a space, where people only have "edit properties" rights. An "OnUpdate" behavior kicks in the generator again. With the version management in 3.2, that should even give your versioning of your edits. So they can edit questions and answers, but cant mess with the results. And you can reuse the HTML or XML files for displaying as snippets whereever you need it.

Norgan

kooroshv
Champ in-the-making
Champ in-the-making
Thanks for all the suggestions. I will research them and see how far I can get with them.

Koorosh

norgan
Champ in-the-making
Champ in-the-making
Hi,
maybe I was asleep, but somehow I missed the d:content part - maybe that content field is somehow treated differently. So two other answers using the content modell :
a) How about just using "d:text" with the component generator set to a bigger size ? You dont have the HTML formatting for that,
b) if you want formated answers, store the question as metadata and the answer in the standard "content" field  witht he question as 1st line in the content. Then use a behaviour to extract the first line on update and store it in the property "custom:question".

Norgan