how to create metadata template from scratch

cancel
Showing results for 
Search instead for 
Did you mean: 
kzala7
Active Member II

how to create metadata template from scratch

Jump to solution

i'm stuck from past 1 week for this topic , not able to create my own metadata content template 

how many files are to be created and what are the dependency needed?

i'm not able to figure it out properly 

i have gone through all the alfresco documentation online and also with so many links but no progress at all 

previously i mentioned this question even though i couldn't make it out of it

please help me with this metadata creation from basic steps from where exactly should i start creating metadata template 

metadata template for eg it could be any document like Sales document with it's required metadata like document id , name, sales period etc etc.. 

give me the steps or provide some sample template for it so it could be great pleasure.

thank you                                                                                                                                            

1 Solution

Accepted Solutions
sanjaybandhniya
Intermediate

Re: how to create metadata template from scratch

Jump to solution

Hi,

I have used sdk2 for this type of configuration.

1)Create Content model and deploy it.

Step-By-Step: Creating A Custom Model

2)Configure you custom metedata with custom form

Displaying type metadata | Alfresco Documentation 

3) Create button to create custom content(you can add this control to create content menu also)

share\src\main\amp\config\alfresco\web-extension\site-data\extensions\xxx.xml

<extension>
<modules>
   <module>
     <id> Custom Document Lirary Button</id>
      <version>1.0</version>
      <auto-deploy>true</auto-deploy>
   <customizations>
      <customization>
      <targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>
      <sourcePackageRoot>com.org.components.documentlibrary</sourcePackageRoot>
  </customization>
</customizations>
</module>
</modules>
</extension>

config\alfresco\web-extension\site-webscripts\com\org\components\documentlibrary\documentlist-v2.get.html.ftl

<@markup id="documentlist-dependencies" target="js" action="after" scope="global">
<@script type="text/javascript" src="${url.context}/res/js/components/documentlibrary/extensions/custom-documentlist.js" group="documentlibrary"/>
</@markup>

config\alfresco\web-extension\site-webscripts\com\org\components\documentlibrary\documentlist-v2.get.js

for (var i=0; i<model.widgets.length; i++) {

   if (model.widgets[i].id == "DocumentList") {

      model.widgets[i].name = "ORG.components.DocumentList";

} }

src\main\amp\web\js\components\documentlibrary\extensions\org-documentlist.js


if (typeof ORG == undefined || !ORG) {

var ORG = {};
}
if (!ORG.components) {
ORG.components = {};
}


(function() {
var $siteURL = Alfresco.util.siteURL;
ORG.components.DocumentList = function CustomDocumentList_constructor(htmlId) {
ORG.components.DocumentList.superclass.constructor.call(this, htmlId);
return this;
};

YAHOO.extend(ORG.components.DocumentList, Alfresco.DocumentList,
{
onReady: function CustomDL_onReady()
{

ORG.components.DocumentList.superclass.onReady.call(this);
var elms=Dom.getElementsByClassName("left");
var spn=document.createElement('span');
var btn = document.createElement('button');
var t = document.createTextNode("Computer & Mobile");
btn.appendChild(t);
btn.onclick= this.onButtonClick;
spn.setAttribute('class','yui-button yui-push-button');
spn.appendChild(btn);
elms[0].appendChild(spn);
},
onButtonClick: function CustomDL_onButtonClick(e, p_obj)
{
var toolbar = Alfresco.util.ComponentManager.findFirst("Alfresco.DocListToolbar");
var actions = toolbar.modules.docList;
var destination = toolbar.doclistMetadata.parent.nodeRef;
var doBeforeDialogShow = function DLTB_onNewFolder_doBeforeDialogShow(p_form, p_dialog)
{
Dom.get(p_dialog.id + "-dialogTitle").innerHTML = "Header";
Dom.get(p_dialog.id + "-dialogHeader").innerHTML = "Title";
};
var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT + "components/form?itemKind={itemKind}&itemId={itemId}&destination={destination}&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
itemKind: "type",
itemId: "custom-type", // Here define your custom type that you have defined in content-model
destination: destination,
mode: "create",
submitType: "json",
formId: "doclib-common"
});
var createFolder = new Alfresco.module.SimpleDialog(toolbar.id + "-createFolder");
createFolder.setOptions(
{
width: "58em", templateUrl: templateUrl, actionUrl: null, destroyOnHide: true,
doBeforeDialogShow:
{
fn: doBeforeDialogShow,
scope: this
},
onSuccess:
{
fn: function DLTB_onNewFolder_success(response)
{
var activityData;
var folderName = response.config.dataObj["prop_name"];
var folderNodeRef = response.json.persistedObject;
activityData =
{
fileName: folderName,
nodeRef: folderNodeRef,
path: toolbar.currentPath + (toolbar.currentPath !== "/" ? "/" : "") + folderName
};
toolbar.modules.actions.postActivity(toolbar.options.siteId, "folder-added", "documentlibrary", activityData);

YAHOO.Bubbling.fire("folderCreated",
{
name: folderName,
parentNodeRef: destination
});
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.new-folder.success", folderName) });}, scope: this},
onFailure:
{
fn: function DLTB_onNewFolder_failure(response)
{ if (response){
var folderName = response.config.dataObj["prop_name"];
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.new-folder.failure", folderName)});
}else{
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.failure") }); }
createFolder.widgets.cancelButton.set("disabled", false);
},scope: this
}});
createFolder.show();
return createFolder;}});})();

View solution in original post

8 Replies
sanjaybandhniya
Intermediate

Re: how to create metadata template from scratch

Jump to solution

Hi,

Do you want to create your content with custom property same way as alfresco is creating(Folder with name,title,description,Plain text with name,content,title,description)?

kzala7
Active Member II

Re: how to create metadata template from scratch

Jump to solution

Yes

sanjaybandhniya
Intermediate

Re: how to create metadata template from scratch

Jump to solution

Hi,

I have used sdk2 for this type of configuration.

1)Create Content model and deploy it.

Step-By-Step: Creating A Custom Model

2)Configure you custom metedata with custom form

Displaying type metadata | Alfresco Documentation 

3) Create button to create custom content(you can add this control to create content menu also)

share\src\main\amp\config\alfresco\web-extension\site-data\extensions\xxx.xml

<extension>
<modules>
   <module>
     <id> Custom Document Lirary Button</id>
      <version>1.0</version>
      <auto-deploy>true</auto-deploy>
   <customizations>
      <customization>
      <targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>
      <sourcePackageRoot>com.org.components.documentlibrary</sourcePackageRoot>
  </customization>
</customizations>
</module>
</modules>
</extension>

config\alfresco\web-extension\site-webscripts\com\org\components\documentlibrary\documentlist-v2.get.html.ftl

<@markup id="documentlist-dependencies" target="js" action="after" scope="global">
<@script type="text/javascript" src="${url.context}/res/js/components/documentlibrary/extensions/custom-documentlist.js" group="documentlibrary"/>
</@markup>

config\alfresco\web-extension\site-webscripts\com\org\components\documentlibrary\documentlist-v2.get.js

for (var i=0; i<model.widgets.length; i++) {

   if (model.widgets[i].id == "DocumentList") {

      model.widgets[i].name = "ORG.components.DocumentList";

} }

src\main\amp\web\js\components\documentlibrary\extensions\org-documentlist.js


if (typeof ORG == undefined || !ORG) {

var ORG = {};
}
if (!ORG.components) {
ORG.components = {};
}


(function() {
var $siteURL = Alfresco.util.siteURL;
ORG.components.DocumentList = function CustomDocumentList_constructor(htmlId) {
ORG.components.DocumentList.superclass.constructor.call(this, htmlId);
return this;
};

YAHOO.extend(ORG.components.DocumentList, Alfresco.DocumentList,
{
onReady: function CustomDL_onReady()
{

ORG.components.DocumentList.superclass.onReady.call(this);
var elms=Dom.getElementsByClassName("left");
var spn=document.createElement('span');
var btn = document.createElement('button');
var t = document.createTextNode("Computer & Mobile");
btn.appendChild(t);
btn.onclick= this.onButtonClick;
spn.setAttribute('class','yui-button yui-push-button');
spn.appendChild(btn);
elms[0].appendChild(spn);
},
onButtonClick: function CustomDL_onButtonClick(e, p_obj)
{
var toolbar = Alfresco.util.ComponentManager.findFirst("Alfresco.DocListToolbar");
var actions = toolbar.modules.docList;
var destination = toolbar.doclistMetadata.parent.nodeRef;
var doBeforeDialogShow = function DLTB_onNewFolder_doBeforeDialogShow(p_form, p_dialog)
{
Dom.get(p_dialog.id + "-dialogTitle").innerHTML = "Header";
Dom.get(p_dialog.id + "-dialogHeader").innerHTML = "Title";
};
var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT + "components/form?itemKind={itemKind}&itemId={itemId}&destination={destination}&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
itemKind: "type",
itemId: "custom-type", // Here define your custom type that you have defined in content-model
destination: destination,
mode: "create",
submitType: "json",
formId: "doclib-common"
});
var createFolder = new Alfresco.module.SimpleDialog(toolbar.id + "-createFolder");
createFolder.setOptions(
{
width: "58em", templateUrl: templateUrl, actionUrl: null, destroyOnHide: true,
doBeforeDialogShow:
{
fn: doBeforeDialogShow,
scope: this
},
onSuccess:
{
fn: function DLTB_onNewFolder_success(response)
{
var activityData;
var folderName = response.config.dataObj["prop_name"];
var folderNodeRef = response.json.persistedObject;
activityData =
{
fileName: folderName,
nodeRef: folderNodeRef,
path: toolbar.currentPath + (toolbar.currentPath !== "/" ? "/" : "") + folderName
};
toolbar.modules.actions.postActivity(toolbar.options.siteId, "folder-added", "documentlibrary", activityData);

YAHOO.Bubbling.fire("folderCreated",
{
name: folderName,
parentNodeRef: destination
});
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.new-folder.success", folderName) });}, scope: this},
onFailure:
{
fn: function DLTB_onNewFolder_failure(response)
{ if (response){
var folderName = response.config.dataObj["prop_name"];
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.new-folder.failure", folderName)});
}else{
Alfresco.util.PopupManager.displayMessage(
{ text: toolbar.msg("message.failure") }); }
createFolder.widgets.cancelButton.set("disabled", false);
},scope: this
}});
createFolder.show();
return createFolder;}});})();

kzala7
Active Member II

Re: how to create metadata template from scratch

Jump to solution

thanks for the help.

and what is above code for?

can you give any idea for that?

and can you tell me how to create custom pages and provide this above content in it? 

sanjaybandhniya
Intermediate

Re: how to create metadata template from scratch

Jump to solution

This code is used to create custom content like create folder/plain text.

kzala7
Active Member II

Re: how to create metadata template from scratch

Jump to solution

can i use default custom model for my use?

cesarista
Customer

Re: how to create metadata template from scratch

Jump to solution

Hi:

A simple example is here:

https://github.com/zylklab/zk-url-shortener 

In zylklab there are other examples, that use metadata templates for custom models.

GitHub - zylklab/zk-qshared-effectivity: Public url documents (qshared) with effectivity in Alfresco... 

https://github.com/zylklab/zk-zpm-statusable 

Regards.

--C.

kzala7
Active Member II

Re: how to create metadata template from scratch

Jump to solution

Thanks Cesar Sir