FLUID Link with target and class

2.3k views Asked by At

I wrote a small Frontend Plugin "Text+Image+Link". If my editor choose a file link or an external Link, he also assign to open the target in a new window: _blank

In my Fluid-Tempalte I wrote

<f:link.page pageUid="{txtTarget}" class="btn btn-default">{txtLink}</f:link.page>

But there's no support to the link target, here's the output:

<a class="btn btn-default" href="http://kbs2015.com">Read more</a>

There's no target-attribute, but I chose it at Link Wizard (flexform): target:_blank !?

-

I try it like this:

<f:format.html><link {txtTarget}>{txtLink}</link></f:format.html>

There's the right link and target but no CLASS! Output:

<a href="http://kbs2015.com" target="_blank">Read more</a>

- How can I use target (from wizard) and two classes for a Link in FLUID? DO I need a new ViewHelper? I don't know? Can I solve my problem with Fluid?

Thanks for your help.

( TYPO3 6.2.8 )

2

There are 2 answers

5
derhansen On

It depends on which TYPO3 version you use. TYPO3 7.0 has a new ViewHelper (TypolinkViewHelper) which handles Typolinks created with the link wizzard and respects link targets. In TYPO3 4.5 and TYPO3 6.2 there is no such viewhelper, so you should try to backport the viewhelper from TYPO3 7.0 to your extension.

Copy the content from the linked viewhelper to the Viewhelpers directory of your extension and adjust the namespace to match the one from your extension. Then you can use the viewhelper in your extension.

0
user2310852 On

It won't work if I copied the TypolinkViewHelper from TYPO3 CMS 7.0 I've got always the error

Error Warning: Could not analyse class:Tx_MyExtension_ViewHelpers_Link_TypolinkViewHelper maybe not loaded or no autoloader? 

I try it successfully with a Test-ViewHelper, but they not with the TypolinkViewHelper.php

Anyway ... I solve it with this FLUID-Snippet:

<f:format.html><link {txtTarget}><span class="btn btn-default">{txtLink}</span></link></f:format.html>