简体   繁体   中英

Create TYPO3 Fluid link for typolink fields generated by a link wizard

I regularly use the link wizard in my TCA.

Its horrible to find out with conditions which kind of link I have to render in Fluid (page/email/external). Is there a solution for this or do I have to create my own ViewHelper?

It seems to be undocumented, but you can pass it to <f:link.page> and it will be rendered correctly, even if it is external, email, or file link. This is because internally, <f:link.page> uses UriBuilder to build the URL, and that UriBuilder uses Typolink.

<f:link.page pageUid="{myLinkFieldValue}">My link</f:link.page>

这是我为此使用的 ViewHelper(+ 一个助手类): https : //gist.github.com/BenjaminBeck/7220623

I think the link.typolink ViewHelper is what you are looking for, at least for TYPO3 7.0 and above.

<f:link.typolink parameter="{link}">
   Linktext
</f:link.typolink>

 External Link -- <f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external> Email -- <f:link.email additionalAttributes="{foo: 'bar'}" email="NULL" class="NULL" dir="NULL" id="NULL" lang="NULL" style="NULL" title="NULL" accesskey="NULL" tabindex="123" onclick="NULL" name="NULL" rel="NULL" rev="NULL" target="NULL"> <!-- tag content - may be ignored! --> </f:link.email> Internal Link -- <f:link.page pageUid="1" additionalParams="{extension_key: {foo: 'bar'}}">page link</f:link.page>

In Fluid, there are different link view helpers:

<f:link.action action="show">action link</f:link.action>
<f:link.email email="foo@bar.tld" />
<f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external>
<f:link.page>page link</f:link.page>

The Code (and some examples) can be found at: typo3/sysext/fluid/Classes/ViewHelpers/Link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM