How do I associate one piece of content with another in Alfresco? - alfresco

I have two folders, one full of images and another full of text files.
How do I add a property to the text file that allows the user to pick an item from the image folder? (I know how to add basic properties like numbers and dates using aspects.)
I already tried these, but Share renders them as read-only boxes.
<property name="my:propQName">
<title>QName Property</title>
<type>d:qname</type>
</property>
<property name="my:propNodeRef">
<title>Node Reference Property </title>
<type>d:noderef</type>
</property>
<property name="my:propPath">
<title>Path Property </title>
<type>d:path</type>
</property>

You need to create an association:
<associations>
<association name="my:relatedImage">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>my:imageType</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
</associations>
This will render by default as a picker. You can always configure the picker as usual in share-config-custom.xml.
EDIT: official documentation on associations

Related

Add Image in background using default.css in eclipse e4

I am creating a Eclipse e4 RCP Application. I want to add a image at the background. I have tried adding property in plugin.xml:
<property
name="applicationCSSResources"
value="platform:/plugin/rcptutorial/image/image.jpg">
Also, I created a new folder "Images" and added "image.jpg in it. I also added the line in default.css:
Shell { background-image: url('./image.jpg');}
But nothing happens when I run it. I can apply background-color but unable to add image.
Please help.
My Plugin.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="product"
point="org.eclipse.core.runtime.products">
<product
name="org.rcptutorial.rcp"
application="org.eclipse.e4.ui.workbench.swt.E4Application">
<property
name="lifeCycleURI"
value="bundleclass://rcptutorial/org.rcptutorial.rcp.E4LifeCycle">
</property>
<property
name="applicationCSS"
value="platform:/plugin/rcptutorial/css/default.css">
</property>
<property
name="applicationCSSResources"
value="platform:/plugin/rcptutorial/images/">
</property>
</product>
</extension>
</plugin>
My default.css is as follows:
Shell { background-image: url('./images/image.jpg');}
I have an "images" folder that contains the image "image.jpg". The folder is located inside my project
applicationCSSResources must specify a folder which contains the images:
<property
name="applicationCSSResources"
value="platform:/plugin/rcptutorial/image/">
</property>
(the ending '/' must be present).
The URL in the CSS should just be:
url('./image.jpg')

Alfresco: Define a custom type that contains files as properties

I would like to create a custom model for a whitepaper that consists of the following properties:
Published Date
Author
Audio File
PDF File
How can I specify that two of the last two are files?
<types>
<type name="sc:whitepaper">
<title>Whitepaper</title>
<parent>cm:content</parent>
<properties>
<property name="sc:publishedDate">
<type>d:datetime</type>
</property>
<property name="sc:author">
<type>d:text</type>
</property>
<property name="sc:audioFile">
<type>d:text</type> <!-- How do I state this property is a file? -->
</property>
<property name="sc:pdfFile">
<type>d:text</type> <!-- How do I state this property is a file? -->
</property>
</properties>
</type>
</types>
It might be a bad idea doing that. Amongst other things, the system will not give you decent ootb support to search or access the values. Make sure to check associations as an alternative.
That said, if you still want to do that, use a property of type d:content. Have a look at http://wiki.alfresco.com/wiki/Data_Dictionary_Guide for further details.
One of the way is to create association i would advice you to do this:
<associations>
<association name="sc:pdfFiles">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:content</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
Or if this does not fix your problem you can set that property to be of type <type>d:content</type>.
Like so:
d:content
If you are not familiar with custom models you can read more here
http://alfrescoblog.com/2014/05/19/alfresco-tutorial-custom-content-types/
Hope it helps.

Custom type not showing up in rule config

Trying to add a folder rule which should specialize cm:content to our custom type my:content (which inherits from cm:content).
We have configured the following in share-config-custom.xml:
<type name="cm:content">
<subtype name="my:content"/>
</type>
Our type shows up correctly in the specialize type action in the document library, but when trying to specify a rule the listbox that should contain our type remains empty. :(
What could we be missing?
You need to add to web-client-config-custom.xml in alfresco/extension
<config evaluator="string-compare" condition="Action Wizards"
replace="true">
<subtypes>
<type name="my:content" />
</subtypes>
<specialise-types>
<type name="my:content" />
</specialise-types>
</config>
And then the trick is to provide title & description for the types in the content model or via messages/properties; otherwise they will not be there.
Wrote about similar issues here: http://experiencewithalfresco.blogspot.dk/2012/08/remember-to-define-title-and.html
For adding custom messages you need to create custom-message-context.xml
<beans>
<bean id="mycompany.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
<property name="resourceBundles">
<list>
<value>alfresco.messages.custom</value>
</list>
</property>
Then create custom.properties file and place it in /shared/classes/alfresco/message folder.
And for adding custom type to rule your config should be working only thing to make sure is config inside which you have put sub-type related config is proper.
Disclaimer: This answer is for Alfresco 6.2.2+.
Answering an old thread. For me, I tried this thread all vague answers on Alfresco Hub and nothing worked out.
I have been through this nightmare. Its frustrating and I don't know why Alfresco team relies on "Display Label" instead of "Name".
As shown in the screenshot, I was missing Display Label. As soon as I edited my custom type and provided Display Label, all worked as expected.
If I would have designed it, I would include, Name and Display Label both in the drop down in my rule window.
Hope it helps someone like me.

What is the purpose of <role> within association definition in a content model?

I noticed this within the person model (Didn't pick up on it the first time):
<associations>
<association name="cm:avatar">
<source>
<role>cm:avatarOf</role> <!-- What is the purpose of this?? -->
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:content</class>
<role>cm:hasAvatar</role>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
I am duplicating this association for my own model and would like to know it's significance of this element within associations.
The info is informational only, the value can even be retrieved via the JavaScript API.
Information can be found here: https://issues.alfresco.com/jira/browse/MNT-7403

Is it possible to add a description or help text to an aspect's property in Alfresco Share?

Is it possible to add a description or help text to an aspect's property in Alfresco Share? I cannot change the title because it would require too much text.
When defining your type or aspect, you can set both a title and description. These will generally be shown in Forms, in Share and Explorer, and are normally the easiest way to explain to both users and developers about your model.
To see this in use, take a look at the audio:audio aspect in Alfresco, the latest version is available here. You'll see some of the aspect properties have both a title and a description. If you upload an MP3 into Alfresco 4, and edit the metadata for it in Share, you should see that information show up.
As a general guide though, your aspect should look something like:
<aspect name="test:thing">
<title>Testing Content</title>
<description>Aspect applied to mark content as being for testing use</description>
<properties>
<property name="test:edition">
<title>Test Edition</title>
<description>Which testing edition does this belong to?</description>
<type>d:int</type>
</property>
<property name="test:notes">
<title>Test Notes</title>
<description>Notes for using this content in testing</description>
<type>d:text</type>
</property>
</properties>
</aspect>
If you're going to be using your type or aspect in a multi-lingual system, then you should look at the Model Localisation Guide for information on how to specify names, titles and descriptions from properties bundles which can be localised

Resources