[MGNLDAM-621] Property "name" on JcrAsset is very hard to obtain with ftl only Created: 29/Sep/15 Updated: 12/Mar/21 Resolved: 12/Mar/21 |
|
| Status: | Closed |
| Project: | Magnolia DAM Module |
| Component/s: | None |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Type: | Story | Priority: | Neutral |
| Reporter: | Christoph Meier | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Date of First Response: | |||||||||
| Description |
|
DAM app (based on jcr assets) has a jcr property "name". To obtain the property with ftl you must fetch the jcr node first, otherwise - directly on the asset - seems impossible. When adding an asset, 2 properties are set automatically with the name of the node (actually with the name of the uploaded image/file). To improve the situation - the implementation of JcrAsset#getName() could be changed. Currently JcrAsset#getName() always returns the name of the node. Instead the method should try to return the jcr property "name" - if failing fall back to the file name. |
| Comments |
| Comment by Christoph Meier [ 29/Sep/15 ] |
|
I've created a little ftl macro to tyr out this stuff:
[#macro assetNameBrainFuck assetRef]
<div>
[#if assetRef??]
[#assign asset = damfn.getAsset(assetRef) /]
[#if asset??]
asset.name = ${asset.name!""}<br/>
asset.class.name = ${asset.class.name!""}<br/>
asset.node.name = ${asset.node.name!""}<br/>
[#assign assetMap = damfn.getAssetMap(asset)]
assetMap.name = ${assetMap.name!""}<br/>
[#--asset.getItemKey().getAssetId() = ${asset.getItemKey().getAssetId()}<br/>--]
[#assign damJcrNode = cmsfn.asJCRNode(cmsfn.contentById(asset.getItemKey().getAssetId(), "dam")) /]
[#if damJcrNode??]
damJcrNode@name = ${damJcrNode.getProperty("name").getString()}<br/>
[#else]
no damJcrNode<br/>
[/#if]
[/#if]
[/#if]
</div>
[/#macro]
|
| Comment by Magnolia International [ 29/Sep/15 ] |
|
The problem is that JcrAsset (JcrAssetProvider) systematically returns node.getName(), while it should [maybe|probably] look at the name property before falling back on the node name. |