How to extend ftl display template in alfresco share? - alfresco

I have the following xml customisation to deploy my customisations declared:
<module>
<id>Global changes</id>
<auto-deploy>true</auto-deploy>
<!-- Enhance individual WebScripts when their paths match -->
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>fr.mypackage</sourcePackageRoot>
</customization>
</customizations>
</module>
and I'm trying to add an additional CSS to header.get.html.ftl so I created, under the following path, webscripts/fr/mypackage/components/header/ a header.get.html.ftl and added the following to it :
<#markup id="css-additional" target="css" action="after" scope="global">
<#link href="${url.context}/res/themes/${theme}/css/global-header.css" group="header"/>
</#>
But the css isn't added to the header. Am I missing an important step here?
Edit: I should add I'm working on 4.2.e if this helps.

I think they changed it in 4.2, take a look at http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-1/
Here the source package should be: <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>

Related

Why doesn't my Share header customization work on the search page

This is question gets asked repeatedly in the Alfresco JIRA, in forums and on the Alfresco IRC so I thought I would ask and answer it here as this is the most likely place that people will find the solution, the question is this...
I've created a customization to the Alfresco Share header following
the steps described in this blog post to remove a menu item.
However, when I login to Alfresco that the customization works on
everything except the search page - What am I doing wrong?
The search page in Alfresco Share is one of the few full Aikau pages in the application. The majority of the pages in Share were written before Aikau was created and are comprised of multiple Surf Components - of which the header has been rendered by Aikau since version 4.2.
The search page was updated in 5.0 to be a full Aikau page and does not use the same Surf Component to render the header.
This means that the standard header customization will only be targeting the Surf Component WebScript and not the full page WebScript.
To get this to work you need to take advantage of the alwaysApply element in the module configuration.
So for example a typical extension module to target the header might look like this:
<extension>
<modules>
<module>
<id>Extension Module</id>
<auto-deploy>true</auto-deploy>
<evaluator type="default.extensibility.evaluator"/>
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>org.alfresco.share.pages.customizations</sourcePackageRoot>
</customization>
</customizations>
</evaluator>
</module>
</modules>
</extension>
This would be targeting all WebScripts in the org.alfresco package and would look for matching files in the org.alfresco.share.pages.customizations package.
So the Share header is defined by the share-header.get.js WebScript, and if your extension file should be in org.alfresco.share.pages.customizations.share-header.get.js.
However, the org.alfresco.share-header.get.js WebScript is not used on the search page, which is why the customization will not take effect.
Instead, you should include an additional customization block to ensure your extension is applied, it should look similar to this:
<customization>
<targetPackageRoot>org.alfresco.share.pages</targetPackageRoot>
<sourcePackageRoot>org.alfresco.share.pages.customizations.share.header</sourcePackageRoot>
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
This says that for all WebScripts in the org.alfresco.share.pages package (which is where all full Aikau pages are defined). You should always apply extension files called "share-header" (so .get.js, .get.html.ftl and .get.properties files would also be matched).
Note that the sourcePackageRoot is defines exactly where the extension file should be found.

how to access alfresco-global.properties from FTL based on environments

I have extended the footer page that is deployed as a separate jar in alfresco share[webapps/share/WEB-INF/lin/xx.jar] and try to display the value in ftl file by reading the value from alfresco-global.properties that is placed in the below path.Is it possible to display the value in ftl file from global properties file?This value should be changed based on environments.
C:\Alfresco\tomcat\shared\classes
alfresco-global.properties
displayValue=xyz
footer.get.html.ftl
<#markup id="footer-extension-html" target="html" action="replace" scope="global">
<#uniqueIdDiv>
<div class="footer ${fc.getChildValue("css-class")!"footer-com"}">
<span class="copyright">
<img src="${url.context}/res/components/images/${fc.getChildValue("logo")!"alfresco-share-logo.png"}" alt="${fc.getChildValue("alt-text")!"Alfresco Community"}" border="0"/>
<#if licenseHolder != "" && licenseHolder != "UNKNOWN">
<span class="licenseHolder">${msg("label.licensedTo")} ${licenseHolder}</span><br>
</#if>
<span>${msg(fc.getChildValue("label")!"label.copyright")}</span><br><br>
<span style='margin-left:175px;'><font size="1">Display Value*******</font>:<b><font face="verdana" color="green">${displayValue}</font></b></span>
</span>
</div>
</#>
</#>
footer-extension.xml
<extension>
<modules>
<module>
<id>application Footer Extension</id>
<description>Display Value</description>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<sourcePackageRoot>com.xxxts.components.footer</sourcePackageRoot>
<targetPackageRoot>org.alfresco.components.footer</targetPackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
Basically you can't access the global properties from a FreeMarker template as you are trying to do. The fundamental reason for this is that global properties are configured for the Alfresco Repository, not Share.
If you want to access configurable properties you're better off defining them in the XML configuration files used by Share.
This question is asked and answered in more detail here on the Alfresco Forums.

How to override popup.pt in Plone?

I was able to modify the original popup.pt and see changes in my instance, but when I try to override it by copying and renaming to archetypes.referencebrowserwidget.browser.popup.pt in my theme/(add-in) overrides folder I am unable to see my changes.
I overrode the path_bar class viewlet, following this tutorial. I attempted to follow the same logic for overriding popup.pt, but I was unable to get Plone to see the file in my configure.zcml.
configure.zcml:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="mytheme.theme">
<includeDependencies package="." />
<plone:static
directory="resources"
type="theme"
/>
<genericsetup:registerProfile
name="default"
title="mytheme.theme"
directory="profiles/default"
description="Installs the mytheme.theme package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<browser:viewlet
name="plone.path_bar"
manager="plone.app.layout.viewlets.interfaces.IAboveContent"
class=".customizations.PathBarViewlet"
permission="zope2.View"
layer=".interfaces.IMyTheme"
/>
<browser:page
name="login_main_template"
for="*"
permission="zope.Public"
template="login_main_template.pt"
/>
</configure>
While searching for a solution I found this Stackoverflow question - How to customize the popup.pt template from archetypes.referencebrowserwidget?. I added/:
<include package="z3c.jbot" file="meta.zcml" />
<browser:jbot directory="jbot_templates" layer=".browser.interfaces.IThemeSpecific" />
to my configure.zcml and removed the browser:viewlet from my previous attempt but I was still unable to get Plone to see my overview.
Which method do I need to use to override, the class viewlet, the z3c.jbot, or just the standard copy/rename method? I have read thru the Plone documentation multiple times, but still unable to resolve my issue. If I need to post any additional files please let me know.
Thanks in advance.
The z3c.jbot approach usually just works fine.
You have to be sure, that the file you place into to your jbot_templates folder has the right name.
The path to the popup.pt is archetypes/referencebrowserwidget/browser/popup.pt,
So in your case the filename must be archetypes.referencebrowserwidget.browser.popup.pt
Please make sure that your browserlayer .interfaces.IMyTheme is active on your site -> browserlayer.xml

Creating content of custom type in Share

I am trying to have Share let the user create new documents based on a custom type I implemented (see the excellent documentation here )
I had the type implemented and defined aspects, but I can't see a clear way to configure Share in order to propose in the interface my type for a new document.
I guess it should be added to the Create content menu option that lists available types.
Thanks
You should just modify the share-config-custom.xml file in your tomcat/shared/classes/alfresco/web-extension folder (if there is no such file, search for a similar sample file and rename it). There, you should put something like this in the <config evaluator="string-compare" condition="DocumentLibrary" replace="true"> tag:
<types>
<type name="custom:myType" />
</types>
Just remember if the replace parameter is true, you will override every type visible, so maybe it's better to turn it to false.
Hope it helps
I managed to have it working by adding the following section to the share-custom-config.xml file:
<config evaluator="string-compare" condition="DocumentLibrary">
<create-content>
<content id="plain-text" mimetype="text/plain" label="Brand new content type" itemid="sc:doc"/>
</create-content>
</config>

collective.xdv - define an alternative theme breaks transform for default theme

I'm using plone 4.0.1 + collective.xdv 1.0rc11 and I need to use different themes.
I'm trying to do as described in a recent question/answer but when I insert a new theme with a condition I get no transform at all for the default theme. Here are some examples of what I tried:
<rules css:if-content="body.section-mysection">
<theme href="mysection.html" />
</rules>
this ends in:
Traceback (innermost last):
Module ZPublisher.Publish, line 132, in publish
Module zope.event, line 23, in notify
Module zope.component.event, line 26, in dispatch
Module zope.component._api, line 138, in subscribers
Module zope.component.registry, line 323, in subscribers
Module zope.interface.adapter, line 575, in subscribers
Module plone.transformchain.zpublisher, line 93, in applyTransformOnSuccess
TypeError
While these:
<theme href="mysection.html" if-path="/mysection/"/>
<theme href="mysection.html" css:if-content="body.section-mysection"/>
both work for the given section BUT for the rest of the portal there is no transform at all.
I tried to specify also the default theme in the rules.xml (even if it's already registered into ##xdv-settings) with <theme href="index.html" /> but got no luck.
What am I missing here?
Thanks in advance,
SimO
First, I would consider moving on to plone.app.theming. The upgrade/change is fairly trivial as I understand it (http://pypi.python.org/pypi/plone.app.theming#migrating-from-collective-xdv) and p.a.theming provides all the latest and greatest features that were developed under collective.xdv.
Second, I would reference this document:
http://diazo.org/advanced.html#multiple-conditional-themes
It sounds like you just need to configure the default theme first, and then add a condition(s) to change the appropriate section when the condition matches. The additional matched theme should not affect the "default" (first matched) theme.
I am not sure if I understand your setup and your specific problem to the full extend, so I just post a working example. Note: we don't use a default theme value in the xdv control panel, since it will be obsolete with plone.app.theming anyway. It also seemed to interfere with setting up theme tempaltes in the rules.xml directly which might be relevant for your specific problem/usecase.
<rules
xmlns="http://namespaces.plone.org/xdv"
xmlns:css="http://namespaces.plone.org/xdv+css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<theme css:if-content="body.section-front-page" href="frontpage.html"/>
<theme css:if-content="body.section-contact" href="contact.html"/>
<!-- Only style actual Plone page and exclude things like /manage -->
<rules css:if-content="#visual-portal-wrapper">
<!-- default theme templates -->
<theme href="theme.html" />
<!-- Add your default transform rules here -->
<rules css:if-content="body.section-contact">
<!-- Theme template is already setup on top of this file -->
<!-- Add section specific rules here -->
<drop css:theme="#sidebar" />
</rules>
</rules>
</rules>
These rules are as close as possible to the setup required by diazo/plone.app.theming and should just need minor adjustments (namespace correction and a search/replace for append/after for example) - I just migrated the site this example has been lifted from to Plone4.1/diazo without any major drawbacks.

Resources