Dexterity reorder inherited fields - plone

How do i reorder fields that inherited from an existing behavior within a fields definition that i wrote my self.
For example I want to use the leadimage field (behavior) from plone.app.contenttypes but instead of having it at the bottom of all fields i defined, i want to have it after the description.
I've tried like this:
<property name="model_source">
<model xmlns:security="http://namespaces.plone.org/supermodel/security"
xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
xmlns:form="http://namespaces.plone.org/supermodel/form"
xmlns="http://namespaces.plone.org/supermodel/schema">
<schema>
<field name="image" type="plone.namedfile.field.NamedBlobImage" form:after="description">
<title>Image</title>
</field>
</schema>
</model>
</property>
and btw. is there a more readable way to do this?

form.order_after(image1='ILeadImage.image')
that did the trick, was a little confused within the code example...
followup question:
if i have 3 image field with each having a caption field, do i really have to add that line to every field itself? or is there a way to set the order for all fields in one place like with the fieldset definition?

I never have tried this using XML but the Dexterity XML documentation says it's possible; check the after/before attributes.
I think you can have more control using Python code; check the Form schema hints documentation.

Related

Alfresco custom model with sys:base as parent is having property cm:name

I have created a custom model with parent as sys:base and modified the share-config-custom.xml so that I can create the content from the share. After creating the content from share am unable to see the content in share or explore. Instead am getting the below error when checking from document details page.
The item cannot be found. Either you do not have permissions to view the item, it has been removed or it never existed.
In Node browser I can see cm:name in the property field. But as per the alfresco svn, sys:base is not having the property cm:name.
<type name="sys:base">
<title>Base</title>
<mandatory-aspects>
<aspect>sys:referenceable</aspect>
<aspect>sys:localized</aspect>
</mandatory-aspects>
</type>
Can someone please tell how the custom model get the cm:name property?
Also I want to delete the content. Is there any way to delete that content from share or explore?
Thanks in advance!
To delete your content, call the webscript
/slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}
and send the sys:temporary as an argument.

ReactJS: how to access all child components in parent component?

Suppose I've got comments list component with comments components. I wanna implement method that will return all comments components. I assigned to each comment component same ref:
<comments>
<comment ref="myComments" text="abc" />
<comment ref="myComments" text="efg" />
</comments>
I thought I can access all my components by this.refs.myComments but it doesn't work - it returns only last comment component.
What's the correct way to access all comment components?
There is no correct way to do that.
Your view is a representation of your data, so if you want the text for all comments, look at the data.
If you want to update the comments, update the data.
Pulling data out of the view, or manually manipulating the view defeats the purpose of react.

Change root element in association picker control in Alfresco Share

I'm using Alfresco Share 4.2c and I have to change a root node of an association picker. When I change some property of my document I want that picker directly points to the folder where my document is placed (parent of my document).
My problem is how to access nodeRef of document from association.ftl. I think that one solution is to use page.url.args.nodeRef, find his parent and add pass it to parameter rootNode. I'm not satisfied with that because it works only if I'm on Edit metadata page and my clients also what to use popup window to manage properties which appears on click Edit Properties link.
In that case I don't have nodeRef of document in url.
Do you have any idea how to solve this?
The best way is to a NodeLocator fur such purposes: http://docs.alfresco.com/4.1/concepts/node-locator-intro.html
the ancestor NodeLocator should be sufficient for your needs. Try the following setting in your form configuration:
<field id="my:association">
<control>
<control-param name="startLocation">{ancestor}</control-param>
</control>
</field>

Change link in contents listing for custom content type

I have created a custom content type, based on the existing 'Image' type.
When I look at the contents tab of a parent folder, actual images have a link like this:
.../arumsans/arumsans.png/view
Where my type has a link like this:
.../arumsans/bold
And when clicked shows only the image in the browser.
How can I modify the way these links are made so that my type has
.../arumsans/bold/view
or
.../arumsans/bold/edit
You need to list your type in the typesUseViewActionInListings property of the site_properties property sheet in the portal_properties tool.
To do this manually, navigate to the ZMI, find the tool and click on it, then click on the site_properties sheet, then find the typesUseViewActionInListings entry and add the portal_type of your custom type in that list.
To automate this, add a propertiestool.xml file to the GenericSetup profile of your package that defines the type, and make sure it contains the following:
<?xml version="1.0"?>
<object name="portal_properties" meta_type="Plone Properties Tool">
<object name="site_properties" meta_type="Plone Property Sheet">
<property name="typesUseViewActionInListings" type="lines">
<element value="YourCustomPortalType"/>
</proyerty>
</object>
</object>
(with your portal_type value filled in) and re-import the profile.

Including dynamic component presentations within a rich text field?

Template code can transform TCDL tags into the appropriate content delivery version.
Templates can output:
<tcdl:Link .../>
<tcdl:ComponentPresentation .../>
Delivery side would get tags in this format:
<tridion:ComponentLink ... />
<tridion:ComponentPresentation ... />
Question:
Is it possible to let a content author enter such a dynamic component presentation (DCP) in a rich text field format area? And if so, is a particular format preferred and how should we publish the linked-to DCP?
Edit: added context and changed link to Will's article.
Alternatively could I mimic some syntax similar to this approach from Will Price specifically for SiteEdit using DWT and C# assembly help.
I agree with John, I would implement this as a component link in the RTF. But I wouldn't use any template code, I would instead override Tridion's LinkTagHandler. In the doEndTag method, you can check if you would want to resolve the linked component as a regular dynamic link (in which case you just call the super class), or if you want to insert the DCP there (in which case you can call the ComponentPresentationTagHandler).
You can then configure your taghandler, overriding the Tridion default LinkTagHandler (you can do this in the cd_deployer_conf.xml).
Mind you, I haven't tried any of this, but I don't see why it wouldn't work.
To configure your custom tag handler, add the following to the cd_deployer_conf.xml:
<TCDLEngine>
<Properties>
<!-- keep whatever you have in this section! -->
</Properties>
<Tags>
<Tag Namespace="tcdl" Name="ContentHeader"><Handler Class="com.tridion.tcdl.tags.ContentHeaderTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="Link"><Handler Class="com.mycompany.tridion.extensions.CustomTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="Link"><Handler Class="com.tridion.tcdl.tags.DynamicLinkInfoTracker"/></Tag>
<Tag Namespace="tcdl" Name="TargetGroup"><Handler Class="com.tridion.tcdl.tags.TargetGroupTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="ComponentPresentation"><Handler Class="com.tridion.tcdl.tags.ComponentPresentationTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="FirstLine"><Handler Class="com.tridion.tcdl.tags.FirstLineTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="IncrementTrackingKey"><Handler Class="com.tridion.tcdl.tags.IncrementTrackingKeyTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="PositionMarker"><Handler Class="com.tridion.tcdl.tags.PositionMarkerTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="ContextProperty"><Handler Class="com.tridion.tcdl.tags.ContextPropertyTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="Dependency"><Handler Class="com.tridion.tcdl.tags.DependencyTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="Comment"><Handler Class="com.tridion.tcdl.tags.CommentTagHandler"/></Tag>
<Tag Namespace="tcdl" Name="TaxonomyControl"><Handler Class="com.tridion.tcdl.tags.TaxonomyTagHandler"/></Tag>
</Tags>
</TCDLEngine>
One important note: if you decide to override any of the built-in tag handlers, you need to specify all of them!
Not sure I understand fully the question but here goes:
If a user enters a component link within a rich text field depending on your configuration (type of component presentation and output type) the value will with resolved, most likely to a .
It might be worth having your own c# building block resolve to your own format, then write your own tcdl extension to parse it.
If you're trying to put Tridion component presentation inside component presentations.. I think your data model is a bit (lot!) messed up :)
Will's article refers to SiteEdit only (if I'm not mistaken). Your question is about a generic mechanism on 'including DCPs from a RTF field'.
Allowing other DCPs to be referred to from RTF is, in my view, not very kosher. I would even go as to say it is bad practice. I would avoid mixing content with layout (in the context of DCPs). I think that's something that should be done in a template or via metadata.
I think (D)CPs should be placed on a Page or queried for using some kind of metadata. I would probably prefer to have some taxonomies to tag a DCP against, then in another Component (let's call it a Control Component) you would specify some kind of criteria cocktail regarding which DCPs you want to query and display on the Page. The template will then generate some code (e.g. a custom tag) that would be executed on the Content Delivery side.
Alternatively to your request, maybe a list of links would make more sense for the authors.
Finally, to go back to your requirement, if you choose to go ahead with DCPs in RTF, then I guess it's just a matter of finding a naming convention on how to 'point' to the DCPs from RTF. One possibility would be to use a specially crafted Component Link (maybe with some specific target attribute) that a C# TBB would understand to parse out and replace with a <tridion:ComponentPresentation.../> call. I would use Component Links in an RTF because these links are maintained for integrity, consistency, porting, etc...

Resources