cancel
Showing results for 
Search instead for 
Did you mean: 

Add own content types to Create Content menu

huima
Champ in-the-making
Champ in-the-making
Hi,

I just started to do modifications to Share 3.4a ( Community ) and wondered whether people have experience on what is the proper way to add your own content types into Share's 'Create content'-menu?

As I read through the codebase, I found places where things happen:

- toolbar.lib.ftl template, which draws the menu and lists items, which have links to create content page

- create-content page which uses forms component and has hardcoded configuration to create cm:content


What I had in mind was an ugly hack:

1) hard code my own content item into the menu and create link to create-my-content page

2) create new page to share, which would instead of cm:content be creating our content type


As this includes writing over Share's own files, it does not feel quite good - but should work.

Does anyone else know a better way to do the same thing?

-huima
10 REPLIES 10

calle
Champ in-the-making
Champ in-the-making
Hi
I have done exactly this in 3.3.3 and just changed <itemId> in template.craete-content.create-content.xml to be "dynamic", like:
<itemId>{nodeType}</itemId>

And then in toolbar.lib.ftl submitted the nodetype from the menu like
create-content?nodeType=${content.nodetype}

You must of course create forms for each node-type this way. What I would love is to have the possibility to add aspects during creation (before the form is shown to be able to control the creation even more).

//Carl

huima
Champ in-the-making
Champ in-the-making
Thanks Calle,

for future reference to new customizers, the one thing that made me scratch my head was that forms framework did not work properly if I did not have all the necessary configurations in place.

If I didn't have both:

<config evaluator="model-type" condition="cli:doc">

<config evaluator="node-type" condition="cli:doc">

And proper form configurations, then forms framework generated creation for for cm:content - even though I had configured the component to create form for my cli:doc -type.

This was silly mistake on my behalf, but got me as the framework did not warn about missing configurations or anything.

So hopefully this helps someone with similar troubles in the future.

vmlf
Champ in-the-making
Champ in-the-making
I am using version 3.4b and it seems "create-content" page has changed, I cannot locate the "template.create-content.create-content.xml" file to make this change.
Does anyone know how to get this working in 3.4b version?

thanks,
Vitor Fernandes

vmlf
Champ in-the-making
Champ in-the-making
Finally got this to work in 3.4b. Here is what I did:

First create a custom data model and check it is working by changing type on an existing content to your custom type.
Add form definitions for your custom data types to "share-config-custom.xml". You need to add "node-type" (for viewing/editing) and "model-type" (for creating).

Copy toolbar.get.config.xml to "tomcat\shared\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\documentlibrary", edit and add your custom content with itemId attribute to each content element:


   <createContent>
      <content mimetype="text/plain" itemId="my:customType" icon="plain-text" label="menu.create-content.custom" />
      <content mimetype="text/plain" itemId="cm:content" icon="plain-text" label="menu.create-content.text" />
   </createContent>

Copy toolbar.lib.ftl to "tomcat\shared\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\documentlibrary\include", edit and add itemId param to url changing it to:

<#assign href>create-content?mimeType=${content.mimetype?html}&amp;destination={nodeRef}<#if (content.formid!"") != "">&amp;formId=${content.formid?html}</#if><#if (content.itemId!"") != "">&amp;itemId=${content.itemId?html}</#if></#assign>

Last step I could not get it working on "tomcat/shared" folder, so I had to edit the file directly inside webapps, not ideal!. Go to "tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\documentlibrary\include" and edit "toolbar.lib.js" to parse the itemId attribute from the xml config. Change to:

         createContent.push(
         {
            mimetype: xmlContent.@mimetype.toString(),
            itemId: xmlContent.@itemId.toString(),
            icon: xmlContent.@icon.toString(),
            permission: xmlContent.@permission.toString(),
            formid: xmlContent.@formid.toString(),
            label: xmlContent.@label.toString()
         });

Restart Alfresco and it should work.

Didn't like this much because I had to copy the files which will override the default ones altogether, not just the parts I needed. Is there another way to do this?

mryoshio
Champ in-the-making
Champ in-the-making
Finally got this to work in 3.4b. Here is what I did:

Last step I could not get it working on "tomcat/shared" folder, so I had to edit the file directly inside webapps, not ideal!. Go to "tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\documentlibrary\include" and edit "toolbar.lib.js" to parse the itemId attribute from the xml config. Change to:

Anyone knows about the solution?
I'm facing same problem and want to avoid editing the default toolbar.lib.js in webapps/** .

Any advice would be so helpful.

vigj
Champ in-the-making
Champ in-the-making
i'm very interested too

billerby
Champ on-the-rise
Champ on-the-rise
When implementing this today I noticed that the change in toolbar.lib.js is not needed anymore since that change was commited 2010-12-08 in the Alfresco source code repo. At least the 3.4.d version has this change.

cpaul
Champ on-the-rise
Champ on-the-rise
I've been wrestling with this today using 3.4.5, and it looks like it's an issue specifically with overriding anything in WEB-INF\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\documentlibrary. None of these files are getting picked up for me. The alternative seems to be placing the files in tomcat\shared. See this issue: https://issues.alfresco.com/jira/browse/ALF-8945

Good news is, this shouldn't be a problem in 4.0. Bad news is there doesn't seem to be a way to extend this in 3.4 (at least from within an AMP).

ltardioli
Champ in-the-making
Champ in-the-making
In Alfresco CE 4.0e I've jus added the follow code on share-config-custom.xml:

<!– Document Library config section –>
<config evaluator="string-compare" condition="DocumentLibrary">
<create-content>
       <content id="plain-text" mimetype="text/plain" label="criar-conteudo.text" itemid="axcl:cliente" icon="ax"/>
</create-content>
</config>

After that I wrote my create-forms and it works well.

If you want to change the icon, just put your 16x16 image on folder: ..\webapps\share\components\images\filetypes and remember to keep ta same name template: ax-file-16.png.