Hide default properties and show aspect properties on Share - alfresco

I'm stuck and I cannot figure out why can achieve this. I'm new to Alfresco, so maybe I'm doing it in a wrong way.
I'm trying to hide default properties on Alfresco Share and only show fields of one of my custom aspects. I mean I want to hide cm:title, cm:name etc.
I'm trying to carry out this by customizing share-config-custom.xml. If I only use <hide> with default properties (without adding custom fields) these are correctly hidden. If I use <show> with my custom properties, both, custom properties and default properties are shown. But the problem is that if I add <hide> and <show> fields, only default fields are shown, although they are seted as hidden.
Here is an example XML:
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<hide id="cm:title" />
<hide id="cm:description" />
<show id="custom:DocumentClass" />
<show id="custom:DocumentDate" />
</field-visibility>
</form>
</forms>
</config>
Thaks in advance.

You can try the following:
Use the hide fields on the cm:content type
Add an extra config and instead of the evaluator="node-type" make it evaluator="aspect"
Add your custom aspect in the new config you just created
If the above doesn't work, try adding replace=true flag to the cm:content config

Related

"external_login_url" customize Plone-login-form

I need to customize Plone login form without make changes in plone original login-form https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/skins/plone_login/login_form.cpt so there are two ways first i use override.zcml to change login-form :
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class="Products.CMFPlone.browser.admin.RootLoginRedirect"
permission="cmf.ManagePortal"
template="templates/login.pt"
/>
and another a simple login.pt file.It generating an Trace:
File "/Plone/buildout-cache/eggs/Products.CMFPlone-4.3.3-py2.7.egg/Products/CMFPlone/browser/admin.zcml", line 43.2-48.8
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class=".admin.RootLoginRedirect"
permission="cmf.ManagePortal"
/>
File "/Plone/buildout-cache/eggs/my_app.egg/my/app/browser/overrides.zcml", line 7.4-12.10
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class=".admin.RootLoginRedirect"
permission="cmf.ManagePortal"
/>
And Second Method: external_login_url in default/propertiesTool.xml i tried but changes not reflected

Customize Plone view class without touching the template

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

Remove default value for a custom property in Advanced search

I'm using Alfresco Share and I have a property with a default value
<property name="my:Property1">
<title>Property1</title>
<type>d:text</type>
<multiple>true</multiple>
<default>0</default>
</property>
I have customised the advanced search
<form id="search">
<field-visibility>
<show id="my:Property1"/>
</field-visibility>
<appearance>
<field id="my:Property1" label-id="Property1">
</appearance>
</form>
In Advanced search this property is initially filled with a default value, in my case with 0. Is there any way to remove that value from a search field?
I guess in this case it's best to create a custom Share Form controller like the textfield.ftl.
In the default controller there is a freemarker entry {field.value}. Just remove this entry throughout the template and there won't be any default value shown.

Alfresco Share - Dynamic rendering of fields in a form

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.

Is it possible to hide the Mime Type and Tags in Alfresco Share?

We don't want our users editing the Mime Type and Tags when they alter a document's properties. Is there a way to hide them from editing in Alfresco Share?
You can configure the visibility of metadata properties by having a share-config-custom.xml file with a proper field-visibility settings. Something like:
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<hide id="mimetype" for-mode="edit" />
<hide id="cm:taggable" for-mode="edit" />
</field-visibility>
</form>
</forms>
</config>

Resources