[MGNLSTK-659] Paragraphs using the tocMacro.ftl are not usable as subparagraphs or from nested calls Created: 08/Jul/10  Updated: 23/Jan/13  Resolved: 08/Jul/10

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: paragraphs
Affects Version/s: 1.3.1
Fix Version/s: 1.3.2

Type: Bug Priority: Major
Reporter: Christian Ringele Assignee: Christian Ringele
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
is causing MGNLSTK-668 tocMarkup.ftl crashes on call Closed
Template:
Acceptance criteria:
Empty

 Description   

The paragraphs 'stkTextImage' and 'stkLinkList' include the macro tocMarkup.ftl:
include "/templating-kit/paragraphs/macros/tocMarkup.ftl"/

The macro tries to read out the pages renderable definition, but does that wrong:
assign intro = model.parent.def.mainArea.intro

this works as long the parent model of the paragraph is a page's model.
But when the paragraph is a subparagraph, the call model.parent will return a renderable definition of a paragraph and not of a page.

the correct solution is:

macro tocMarkup model content

assign rootDef = model.root.def!false

if rootDef.mainArea?if_exists
assign showTOC = rootDef.mainArea.intro.showTOC!false
else
assign showTOC = false
/#if

assign siblings=mgnl.siblings(content)

if showTOC
assign id='id="jump' + (siblings.index + 1) + '"'
else
assign id=""
/#if

/#macro


Generated at Mon Feb 12 07:29:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.