I am new to Tridion. We have a requirement where we need the Component location and name in Content Delivery application side? Is there any way I can achieve that?
The component title is available, but not the location - unless your template outputs that information explicitly. Reason for this is that it could be inaccurate, I could publish a component then move it within the CMS to somewhere else.– Nuno Linhares ♦Jul 23, 2018 at 9:18
Thank you for your quick response. Is there any way to customize com.tridion.cd.linking.ComponentLink logic? We have a requirement to show components in the same page. Resolved URL should point to the common page with the article name for eg: you have two components A & B. Link to A is placeholder page/A and for B it will be placeholder page/B.– Subha SJul 23, 2018 at 9:37
Ah. I misunderstood your question, thought you meant location as “folder in CM”. A dynamic link will give you the url to the closest page containing that component. Try playing around with componentlink class, it will have a property for the URL– Nuno Linhares ♦Jul 24, 2018 at 5:27
"Content Delivery App" - it's not clear if you mean DXA, your own dynamic app, your file-based application etc.
Component "name" - The
Component.Title is available OOTB
Component Location - Assuming you mean the folder (or
folder path) that the
Component is in - it's not available OOTB (DXA you can extend to do this, traditional templating it's pretty easy to get the path etc.). And if you do opt to extend, heed the warning from Nuno that it may not be reliable after the point of publishing.
With regards linking - Dynamic linking has a pre-defined, documented ruleset it adheres to.
Note you can prioritise templates and consider the folder structure to manage this (and as it's a logical pattern it would hopefully be like this already - or make sense to be like this for editorial reasons).
Perhaps clarify which of the link rules is not working with your implementation - and explain why the logic doesn't apply in your specific case?
Note also, we're talking about Component Linking when we're looking at the link resolving rules, of course, Page linking is pretty obvious.