Reputation: 81
I'm trying to create a new type of site. When I'm creating a new one, only appears 1 type in the select: "Collaboration Site". I wish to add more options. For example "Custom Site", and for that site having predefined pages and dashboard. I've got a solution for this but it's modifying presets.xml and share-header.get.js files. I want to do the same by adding my own files, not editing existent files.
Thanks in advance.
Upvotes: 0
Views: 358
Reputation: 10538
You are correct to want to avoid touching out-of-the-box files that came with your Alfresco distribution. You can add new site presets through the standard extension mechanisms.
For example, you should be able to put a presets.xml file in web-extension/site-data/presets that describes your presets. It sounds like you already have an example of what that should look like.
Then, under web-extension/site-webscripts/org/alfresco/modules you can add create-site.get.js which has something like:
var sitePresets = [
{id: "site-dashboard", name: msg.get("title.collaborationSite")},
{id: "some-new-preset", name: msg.get("title.somePreset")}
];
model.sitePresets = sitePresets;
Note that this has changed slightly depending on which version of Alfresco you are using. For example, in 5.2, I don't believe you need to override create-site.get.js as shown above. Instead, you can use a Share extension module. Create a file called presets.xml in web-extension/site-data/extensions:
<extensions>
<modules>
<module>
<id>Additional Site Presets</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>com.someco.presets</sourcePackageRoot>
</customization>
<customization>
<targetPackageRoot>org.alfresco.share.pages</targetPackageRoot>
<sourcePackageRoot>com.someco.presets</sourcePackageRoot>
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
</customizations>
</module>
</modules>
</extension>
With that extension in place you also have to override share-header.get.js. To do that, create a file with that name under web-extension/site-webscripts/com/someco/presets/share/header with this content:
var siteService = widgetUtils.findObject(model.jsonModel, "id", "SITE_SERVICE");
if (siteService && siteService.config)
{
siteService.config.additionalSitePresets = [
{ value: "some-site-preset", label: msg.get("title.someSite") }
];
}
This should add the new "some-site-preset" to the list you see when you create a new site in 5.2.
Upvotes: 1