[MGNLSTK-753] redirect.ftl throws a FreeMarker template error when target page cannot be found Created: 16/Mar/11  Updated: 23/Aug/11  Resolved: 19/Aug/11

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: templates
Affects Version/s: 1.4.2
Fix Version/s: 1.4.5

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

Java 6, Mac OS X 10.6, Safari


Template:
Patch included:
Yes
Acceptance criteria:
Empty
Date of First Response:

 Description   

When you rename a page which is the target of a redirect you will get a FreeMarker template error (at least in edit mode).

This template fixes the problem:

[#assign cms=JspTaglibs["cms-taglib"]]
[@cms.mainBar dialog="stkRedirect" /]
<p style="margin-top:40px">
[#if mgnl.editMode && content.path?has_content]
  [#assign targetContent = mgnl.getContent(content.path)!]
  [#if targetContent?has_content]
    [#assign path="${mgnl.createLink(targetContent)!''}"]
    This page will redirect to <a href="${path}">${path}</a>
  [#else]
    The target page (${content.path!}) could not be found. Please fix the redirect.
  [/#if]
[#else]
  Please define a path where to redirect the request.
[/#if]
</p>

Even better of course would be a redirect template that would store the UUID of the target page instead of the path!



 Comments   
Comment by Magnolia International [ 18/Mar/11 ]

Thanks Will

This doesn't seem to be a patch against 1.4.2 however - would you mind checking ?

http://svn.magnolia-cms.com/svn/community/modules/standard-templating-kit/trunk/magnolia-module-standard-templating-kit/src/main/resources/templating-kit/templates/functional/redirect.ftl

Comment by Christian Ringele [ 22/Jul/11 ]

Ftl does not render error anymore.
Added more checks and i18nized the messages.

Comment by Christian Ringele [ 18/Aug/11 ]

Rendering test is added.

Comment by Jan Haderka [ 19/Aug/11 ]

VersionHandler r476223 - it's written "therefore" not "there for"

Comment by Christian Ringele [ 19/Aug/11 ]

Corrected the spelling.

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