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

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.

Related

Customize RSS dashlet alfresco - feed.utils.ftl

I'm new to freemarker.
I wan't to add more options in the config of the RSS dashlet and use it's value to decide if for example the title of an RSS item should be hidden.
I've found the file feed.utils.ftl which is responsible to show the title.
<#macro renderItem item target="_self">
<div class="headline">
<#if item.image??>
<img align="left" src="${item.image}" alt="" style="padding-right:10px"/>
</#if>
<h4>
<#if (item.link?exists)>
${item.title}
<#else>
${item.title}
</#if>
</h4>
<p>${item.description}</p>
<#if item.attachment??>
<div><img src="${url.context}/res/images/filetypes32/${item.attachment.type}.gif"/>${item.attachment.name}</div>
</#if>
<br />
</div>
</#macro>
There's a corresponding js file, feed.utils.js. I thought I could pass an argument from there to the ftl, for example "model.showTitle". But it has no effect.
The ftl is actively using properties of "item" so I thought maybe I can add my own property to it, but I'm unable to find where these objects are passed to the ftl. Is the macro used to include these?
If you look in share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets you'll find the web script files that implement the RSS dashlet. They are the files that start with rssfeed.
The rssfeed.get.js file is the server-side JavaScript controller for the dashlet.
If you were to add a line in that script's main function to set model.showTitle, you could access that value from the script's freemarker template.
The freemarker file that implements the dashlet is rssfeed.get.html.ftl.
One way to properly override either of these files is to copy them to web-extension and then the exact same package structure below that. Then you can make whatever changes you want without worrying about problems caused by changing the files distributed with Alfresco.
The latest, best approach would be to create a Share Module extension and override the files as part of that, but the copy-and-change approach to overriding is easiest.

How to extend ftl display template in alfresco share?

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>

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>

XSLTApplyError: xsl:comment : '--' or ending '-' not allowed in comment

I am really new to plone and diazo so forgive me if the answer to question is too obvious.
I was asked to create a diazo theme for a website running on plone. Right now i'm at a state where i where i think the theme is reasonably complete(without rules) and i uploded it via .zip to the plone planing to create the rules in plones rules editor. Made a handful of them and hit the preview button to see whether what i am doing is even repotely going into the right direction but hat it showed was this error.
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module plone.app.theming.browser.mapper, line 245, in getFrame
Module lxml.etree, line 567, in lxml.etree.XSLT.__call__ (src/lxml/lxml.etree.c:124426)
XSLTApplyError: xsl:comment : '--' or ending '-' not allowed in comment
After spending quiet some time with a well known search engine i'm still uncertain if that is a mistake i made in the rules.xml or something the websites admin has to look at.
Any and all help will be appreciated.
Edit version information:
Plone 4.3 (4305)
CMF 2.2.7
Zope 2.13.19
Python 2.7.3 (default, Feb 4 2013, 09:04:32) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
PIL 1.7.8 (Pillow)
Edit rules so far
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Apply the following rules to standard Plone pages -->
<rules css:if-content="#visual-portal-wrapper">
<theme href="theme.html" />
<!-- Replace title with Plone's page title -->
<replace css:theme="html head title" css:content="html head title" />
<!-- Copy base tag and script tags from Plone -->
<after css:theme-children="html head" css:content="html head base" />
<after css:theme-children="html head" css:content="html head script" />
<!-- Insert your own rules here -->
<!-- Replace logo with Plone's logo -->
<replace css:theme-children="a#brand img" css:content-children="a#portal-logo img"/>
<!-- Replace top navigation with Plone's top navigation -->
<replace css:theme-children="navbar" css:content-children="ul#portal-globalnav"/>
<!-- Replace search with Plone's search -->
<replace css:theme-children="input.search-query" css:content-children="input#searchGadget"/>
<!-- Replace top navigation with Plone's top navigation -->
<replace css:theme-children="documentDescription" css:content-children="documentDescription"/>
</rules>
</rules>
I didn't create that file myself. It was automatically created by plone upon uploading the .zip without a rules.xml in it. The four(that's how far I got until I first stumbled over the error) rules were created by plones editor.
At first I thought i messed up the comments somehow, seeing that is states "--" and "-" in the error message, but i couldn't find where and DW didn't point out any syntac errors either when opening the file in there.
Edit Solution:
Typo found in the theme.html . One comment ended on "->" instead of "-->" which i never new works for html in the first place.
There's some badly formed XML somewhere. It doesn't appear to be in your rules file. Check the theme file.
Every part of the Diazo processing is done with XML and XSLT processors that depend on the input being well-formed XML (or XSLT). That's just as true of the theme and content as of the rules file.
Content coming from Plone should be good XML (the HTML subset). Your rules file looks OK. That leaves the theme file as a candidate for the problem source.

Embedding a spark variable to make up a string

Hi new to spark so this should be simple.
I'm converting an old webfoms page to mvc using spark.
I want to use the Base.Application to make up the src of a url
original markup
<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />
I've tried this in spark
<img alt= src=${ Base.ApplicationPath }+">images/screenshots/myImage.jpg" />
but no joy.
How do i do this in spark?
Not sure if you're aware of this, but Spark has a DefaultResourcePathManager that will automatically locate the Site Root if you prefix the resource with a tilde, so this should work just fine, and looks neater.
<img alt="" src="~/images/screenshots/myImage.jpg" />
There's an added bonus to using this technique as well....hold on to your shorts! Without changing your view, simply by making sure you use the tilde convention, you can dynamically redirect requests for your static resources to a content delivery network (CDN) or a completely different location - even an embedded resource inside a Spark Module .dll you compile for dll drop in deployment.
For example, to hook it up to a CDN, all you'll need to do is add the following kind of thing to your Spark Settings:
<resources>
<add match="/content/images" location="http://mycdn.com/youraccount/images"/>
<add match="/content/css" location="http://mycdn.com/youraccount/css"/>
<add match="/content/js" location="http://mycdn.com/youraccount/js"/>
</resources>
...and from then on those resources will be fetched from the new location instead. This is great for scenario testing locally, and the deploying to the cloud later.
Slight tweak of the syntax has sorted it.
<img alt="" src="${Base.ApplicationPath}images/screenshots/myImage.jpg" />

Resources