I have a TYPO3 Fluid code like this:
<f:if condition="{data.header_link.url}">
<f:then>
<f:link.typolink parameter="{data.header_link}">My Link</f:link.typolink>
</f:then>
<f:else>
Sorry, no link
</f:else>
</f:if>
Problem: When a link is set, but the target page is disabled, the condition is true and I get "My Link" (just text without link) as output.
Is there a condition to address that issue?
TYPO3 13.4.15
Thanks!
You can check, if the f.uri.typolink viewhelper creates a path.
This should do the job:
<f:if condition="{f:uri.typolink(parameter: data.header_link)}">
<f:then>
<f:link.typolink parameter="{data.header_link}">My Link</f:link.typolink>
</f:then>
<f:else>
Sorry, no link
</f:else>
</f:if>