I have different templates.
default
category
article
overview
They share some properties like the text-editor with it's settings.
<property name="article" type="text_editor">
<meta>
<title lang="de">Inhalt</title>
<title lang="en">Content</title>
</meta>
<params>
<param name="table" value="true"/>
<param name="link" value="true"/>
<param name="paste_from_word" value="true"/>
<param name="height" value="200"/>
<param name="max_height" value="2000"/>
<!-- CKEditor Parameters examples: -->
<param name="extra_allowed_content" value="img(*)[*]; span(*)[*]; div(*)[*]; iframe(*)[*]; script(*)[*]" />
</params>
</property>
I don't want to duplicate the configuration and instead link it from somewhere?
I did not find anything about it in the Sulu-Docs, but I'm sure there is a solution for this.
We've already been thinking about some kind of import functionality, but we haven't implemented that yet, and it has not the highest priority, and would make certain things a bit more complex.
But what you could do until then, is to inherit from the TextEditor Content Type, put your default values in there, register it as a new content type, and use this one instead. Then you would at least save typing the parameters all the time.
If you like you might also be able to use Symfony's Bundle Inheritance feature.
I don't know the Sulu tool but in symfony if you want to factoring code in twig template, you can use the macro twig : Twig macro doc
create a macro file in twig format
import macro file in your template specific page
use a macro in your macro file with call the name of the macro (not the file but the inside macro name file)
With this you can also call the function macro with parameter. For each page generate call this macro with few differents aspects for generate few differents party of this factoring code.
Related
In Alfresco, how to disable actions in multiselect drop down. Assume I have delete couple of files. So i am selecting all those files. Now, if any of the selected files have a specific aspect then the delete option should not be enabled. How can I achieve this?
This is what I tried. But no luck.
<action type="action-link" id="onActionDelete" label="menu.selected-items.delete" notAspect="p:hasSecondaryParent" />
My expectation here is if any of the selected items have "p:hasSecondaryParent" aspect then I do not want the "Delete" action in "Selected Items" drop down. All other time it should display
You need to create action evaluator for that. There is out of box has aspect evaluator available which you need to utilize set your custom aspect in that evaluator. Now add that evaluator in config of delete action. Restart server And that's it.
Ex.
<bean id="evaluator.doclib.indicator.exifMetadata" class="org.alfresco.web.evaluator.HasAspectEvaluator">
<property name="aspects">
<list>
<value>exif:exif</value>
</list>
</property>
This is example from out of box context file you need to replace aspect name and id of evaluator. Then Add this evaluator in your action config.
<config evaluator="string-compare" condition="DocLibActions">
<actions>
<!-- Download document -->
<action id="custom-action" type="link" label="customaction">
<evaluator>evaluator.doclib.indicator.exifMetadata</evaluator>
</action>
</actions>
I have a spring-boot app using that uses spring-mvc with html. No Thymeleaf, no JSP. I would like to be able to apply themes to my app, much the way CMS's such as Joomla and Wordpress do. The problem is that every Spring-MVC Template article/posting talks about either using a single css file, or using something like Tiles. If I have 15 themes, each in their own folder (they typically seem to have many css, js, and html files), I am not sure how I can apply that theme to my app dynamically (selecting via drop down for example).
Has anyone done anything like this? Conceptually I don't see the problem, but short of manually moving each template related file under /template, I don't know how to best accomplish this.
Using Velocity as viewResolver is possible to do it.
I'm using this configuration:
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/views/"/>
<property name="velocityProperties">
<props>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
</props>
</property>
</bean>
<!-- #Velocity -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".vm" />
<property name="layoutUrl" value="layout1.vm" />
<property name="contentType" value="text/html;charset=UTF-8" />
</bean>
The property layoutUrl there is your DEFAULT template, that is a HTML file inside your webapp/WEB-INF/views/ folder:
layout1.vm:
<html>
<body>
<h1>Hello world 1!</h1>
$screen_content
</body>
</html>
The velocity View Resolver will replace $screen_content with the view contents of your controller response:
MyController.java
...
#RequestMapping("/mycontroller")
public String myController() {
return "myView1";
}
...
So, if the view myView1.vm inside webapp/WEB-INF/views/ is something like:
<h2> Foo Bar! </h2>
The result of a request to /myApp/mycontroller would be like:
<html>
<body>
<h1>Hello world 1!</h1>
<h2> Foo Bar! </h2>
</body>
</html>
And if you want to use another TEMPLATE, you can set it dynamically on your controller, setting the value on your Model var:
...
#RequestMapping("/mycontrollerWithADifferentLayout")
public String myController2(Model m) {
m.addAttribute("layout", "layout2");
return "myView1";
}
...
When setting "layout" attribute on model, Velocity will use the provided view as the template.
Found this on Spring Reference:
17.9.2 Defining themes
To use themes in your web application, you must set up an
implementation of the org.springframework.ui.context.ThemeSource
interface. The WebApplicationContext interface extends ThemeSource but
delegates its responsibilities to a dedicated implementation. By
default the delegate will be an
org.springframework.ui.context.support.ResourceBundleThemeSource
implementation that loads properties files from the root of the
classpath. To use a custom ThemeSource implementation or to configure
the base name prefix of the ResourceBundleThemeSource, you can
register a bean in the application context with the reserved name
themeSource. The web application context automatically detects a bean
with that name and uses it.
When using the ResourceBundleThemeSource, a theme is defined in a
simple properties file. The properties file lists the resources that
make up the theme. Here is an example:
styleSheet=/themes/cool/style.css
background=/themes/cool/img/coolBg.jpg The keys of the properties are
the names that refer to the themed elements from view code. For a JSP,
you typically do this using the spring:theme custom tag, which is very
similar to the spring:message tag. The following JSP fragment uses the
theme defined in the previous example to customize the look and feel:
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
<link rel="stylesheet" href="<spring:theme code='styleSheet'/>" type="text/css"/>
</head>
<body style="background=<spring:theme code='background'/>">
...
</body> </html>
By default, the ResourceBundleThemeSource uses an empty base name prefix. As a > result, the properties files are loaded
from the root of the classpath. Thus you would put the cool.properties
theme definition in a directory at the root of the classpath, for
example, in /WEB-INF/classes. The ResourceBundleThemeSource uses the
standard Java resource bundle loading mechanism, allowing for full
internationalization of themes. For example, we could have a
/WEB-INF/classes/cool_nl.properties that references a special
background image with Dutch text on it.
http://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/mvc.html#mvc-themeresolver-defining
If a view is registered like this, with the template definition in zcml:
<browser:page
name="original-view"
class=".original_view.View"
permission="zope2.View"
for="*"
template="original_template.pt"
/>
and i want to customize only his class in my product, is there a way to do it without customizing also the template?
You have to wrap the browser:page by <configure package='XXXX'>
That means your then in scope of this packge.
Example:
<configure package="original.package.browser">
<!-- custom view -->
<browser:page
name="original-view"
class="your.package.browser.View" <!-- Full dotted name to you custom view class -->
permission="zope2.View"
for="*"
layer="your.package.interfaces.IYourPackageLayer" <!-- You should provide a browserlayer, otherwise you got a configuration conflict -->
template="original_template.pt" <!-- template from original.package.browser -->
/>
</configure>
EDIT:
As #sdupton mentioned, I updated the example code snipped with a layer
If you can't use a layer (BrowserLayer) you can put the code, without layer attribute into a overrides.zcml
You can also specify a more precise Interface in the for attribute
My question is more or less in the title, I added a new data type in my data model.
<type name="moi:montype">
<title>titre type</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>moi:monaspect</aspect>
</mandatory-aspects>
</type>
This one uses a new aspect in which I added a new field
<aspect name="moi:monaspect">
<title>titre aspect</title>
<properties>
<property name="moi:monchamp">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
...
</properties>
</aspect>
I then displayed this new field in a Share form by editing the file share-config-custom.xml.
<config evaluator="node-type" condition="moi:montype">
<forms>
<form>
<field-visibility>
<show id="moi:monchamp"/>
...
</field-visibility>
<appearance>
<field id="moi:monchamp" label="Champ texte" />
...
</appearance>
</form>
</forms>
</config>
Till then, I could test my changes and the new field displays well.
But I would like to go further, and condition for example the display of the field depending on the logged in user's group.
If the logged in user is part of the "priviledged group", then the field is displayed, otherwise it will not, or only in read only mode.
Do you think we can do this ? And how ?
I looked at documentation, but can't find my happiness.
I don't ask for the full solution, but for tips to follow.
Thank you for your help.
Every field has a component renderer. These are implemented using FreeMarker. Most of the time, as in your case, you are relying on the default component renderer. In addition to the options mentioned by Matjaz, another option would be to point the field at a custom renderer. The renderer could inspect the user's group membership and the group required for this field (maybe passed in as an argument, for example), and then decide whether or not to show itself.
There are a few ways to do this.
The easiest way is to make a webscript which returns html for a form field based on if a current logged in user is in your target group. Then add a form control which is only javascript making an ajax call to the webscript and and appending results to your container div which is specified in your form control (ftl).
The second approach you could use is to extend "org.alfresco.repo.forms.processor.AbstractFilter" and implement the functionality in Java. You could probably implement after generate and remove the form field if current logged in user is not in a target group.
Hope this helps a bit... :)
There is no easy way to do this as alfresco does not allow you to set rights on node properties.
Every field has control template, you could define your own. in your template you would define how this property is rendered depending of user type.
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<appearance>
<field id="cm:title">
<control template="/org/alfresco/components/form/controls/yourOwnFtl.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
Another approach is to write your own share config form evaluator (like node-type ...)
This could check for node type and user permission role/group
let you write one config for each setup (per user group/role)
...
NB! this will one work for forms, so is purely a cosmetical setup, alfresco interface and CIFS etc. will not support this setup.
Once again back with a Plone question.
I have Plone 4 installed and I need to show the Document action icons at the top instead of bottom. having trouble in getting this to work. can someone help.
If you just need to move that viewlet (with same class and template), first you have to register a viewlet with same class to your desired viewletmanager (let's say for ex. plone.app.layout.viewlets.interfaces.IAboveContentBody):
<browser:viewlet
name="plone.abovecontenttitle.documentactions"
manager="plone.app.layout.viewlets.interfaces.IAboveContentBody"
class="plone.app.layout.viewlets.content.DocumentActionsViewlet"
permission="zope2.View"
/>
and then add this in your genericsetup profile (file viewlets.xml) :
<?xml version="1.0"?>
<object>
<order manager="plone.abovecontentbody" skinname="Plone Default">
<!-- this will place your viewlet before all the others.
you can also use a viewlet's name for a relative position -->
<viewlet name="plone.abovecontenttitle.documentactions" insert-before="*"/>
</order>
<hidden manager="plone.belowcontentbody" skinname="Plone Default">
<viewlet name="plone.abovecontenttitle.documentactions"/>
</hidden>
</object>
More info:
http://plone.org/documentation/kb/customization-for-developers/viewlets
http://collective-docs.readthedocs.org/en/latest/views/viewlets.html