cancel
Showing results for 
Search instead for 
Did you mean: 

Edit-metadata within document-details

dsmith
Champ on-the-rise
Champ on-the-rise
Alfresco version: 5.0.c Community

I have some custom content types that need to be indexed by hand via metadata.  The documents are handwritten so the users need to be able to see the document while they edit the metadata.

When I was first getting my head around Alfresco, I accomplished this by directly editing document-details.xml and document-details.ftl, see <a href="https://forums.alfresco.com/forum/installation-upgrades-configuration-integration/configuration/edit...">here</a>.

But I want to do this the right way (or "a" right way, if there are multiple approaches), so that upgrades don't blow away my customizations.

So currently, I've been following the gist of blog post <a href="http://blogs.alfresco.com/wp/ewinlof/2011/11/09/add-remove-or-replace-components-on-shares-document-...">here</a>, and have created a maven share tier project with the file my-share-project-document-details.xml in my-share-project/src/main/amp/config/alfresco/web-extension/site-data/extensions with the following code:


<extension>
    <modules>
        <module>
            <id>MCRD - Document Details Page</id>
            <evaluator type="default.extensibility.evaluator"/>
            <components>
                    <component>
                            <scope>template</scope>
                            <region-id>document-actions</region-id>
                            <source-id>document-details</source-id>
                            <sub-components>
                                    <sub-component id="edit-metadata-mgr" index="2">
                                            <evaluations>
                                                    <evaluation id="mcrd-edit-metadata-mgr">
                                                            <url>/components/edit-metadata/edit-metadata-mgr</url>
                                                    </evaluation>
                                            </evaluations>
                                    </sub-component>
                                    <sub-component id="edit-metadata" index="3">
                                            <evaluations>
                                                    <evaluation id="mcrd-edit-metadata">
                                                            <url>/components/form</url>
                                                            <properties>
                                                                <itemKind>node</itemKind>
                                                                <itemId>{nodeRef}</itemId>
                                                                <mode>edit</mode>
                                                                <submitType>json</submitType>
                                                                <showCaption>true</showCaption>
                                                                <showCancelButton>true</showCancelButton>
                                                            </properties>
                                                    </evaluation>
                                            </evaluations>
                                    </sub-component>
                            </sub-components>
                    </component>
            </components>
        </module>
    </modules>
</extension>


After activating the module in Share, everything works as expected - the edit properties region shows up alongside the document preview and can be edited and saved.

But I feel like I've accomplished this without knowing exactly what I'm doing or how I'm doing it.  Can anyone confirm that this is a correct way to go about accomplishing my goal or suggest a better way if it's not?

Also, I'm curious what I'd do if I wanted to get a little deeper into customizing the document details.  What if I wanted to adjust the column spacing or create a region for the edit-metadata component, rather than making it a sub-component of document-actions?  I know could directly edit document-details.ftl in the running instance, but how would I accomplish this in the SDK?  I'm working my way through the documentation, but I'm a little overwhelmed by how many ways there are to go about it and wondering if anyone can recommend some reading material more geared toward one approach.
3 REPLIES 3

rjohnson
Star Contributor
Star Contributor
The most future proof way of doing this is via an extension. I have done this on my sites. It takes a bit to piece it together but

https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/40-reusing-existi...

is an excellent place to start.

dsmith
Champ on-the-rise
Champ on-the-rise
Thanks Bob, I'm reading through it now.  I can understand the modifications you ended up making to edit-metadata.ftl (I didn't know about @markup before) but the part I'm still struggling with is how to package modifications to a ftl file into an extension (hopefully via mvn generated AMP files as that's where the rest of my customization has been), rather than just changing the template in-place.

Getting my head around how the SDK structure maps to the installation and when things like Spring and webscripts are necessary has been the most confusing part but hopefully following up on the post you linked to and others will help gel it for me.

Update - Seems like I'm about halfway there after starting to read another <a href="https://blogs.alfresco.com/wp/developer/2011/08/12/customizing-alfresco-share-freemarker-templates/">blog post</a> by Dave Draper.  FTL extensibility seems to be defined by sections demarked by @region directives, or was as of 4.x.

It's when he says something like "Create a file called “dashboard.ftl” and place it in the package “alfresco.templates.blog.demo.customization“" that I'm getting a little confused - how does that package translate to the maven-created file structure of the SDK 2.0?  IE where do I actually put dashboard.ftl?

rjohnson
Star Contributor
Star Contributor
If you email me directly, I'll send you a JAR that will work for you to look at.