[MAGNOLIA-6484] Provide templating function to get first occurrence of a node property Created: 07/Jan/16 Updated: 04/Mar/19 |
|
| Status: | Open |
| Project: | Magnolia |
| Component/s: | templating |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Federico Grilli | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| 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 |
|
Something like
/ * @return a String representation of the first property occurrence, else null. Will search recursively all <code>mgnl:</code> nodes types under the passed root node.
*/
public String findFirstProperty(Node root, String propertyName) throws RepositoryException
This will come in handy in situations like the one we have in demo-travel where the teaser component searches for a teaser image id. Currently this is done within the Freeemarker template with a recursive function but that has some limitations besides introducing perhaps too much complexity in an ftl. |
| Comments |
| Comment by Jan Haderka [ 07/Jan/16 ] |
|
Why not using simply cmsfn.search() for that? |