Check if linked page with typolink is hidden or not

1k views Asked by At

<f:link.typolink parameter="{mylink"> links to a internal page- when this page is hidden / not visible in backend no is set.

This breaks my html:

Instead of

<div class="mylink">
  <a href="mylink">my text</a>
</div>

I get

<div class="mylink">my text/div>

Is there a way to check if the linked page is visible / not hidden?

1

There are 1 answers

0
Mathias Brodala On

You can use the f:uri.typolink viewhelper to check if the resulting URI is empty or not and then generate the link with f:typolink as normal:

<f:if condition="{f:uri.typolink(parameter: mylink)}">
    <f:link.typolink parameter="{mylink}">my text</f:link.typolink>
</f:if>

If you do not care about attributes set in {mylink}, e.g. class or target you can reuse the already generated URI:

<f:alias map="{uri: '{f:uri.typolink(parameter: mylink)}'}">
    <f:if condition="{uri}">
        <a href="{uri}">my text</a>
    </f:if>
</f:alias>