0

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 )

user2310852
  • 1,654
  • 1
  • 25
  • 52

2 Answers2

2

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.

derhansen
  • 5,585
  • 1
  • 19
  • 29
  • I'm using TYPO3 6.2.8. Thanks for your help. I try to use the ViewHelper from TYPO3 7. I hope I can handle this ... – user2310852 Dec 11 '14 at 13:10
  • Should be no problem. I just tested the TypolinkViewhelper with TYPO3 6.2.9 and it works without any problems. – derhansen Dec 11 '14 at 13:18
  • Hi, I copied the TypolinkViewHelper and it works. But first I add it to the TYPO3 Core: typo3 / sysext / fluid / Classes / ViewHelpers / Link / TypolinkViewHelper.php (not good for updates I know) But when I added the TypolinkViewHelper into my_extension, I've got an Error Warning: Could not analyse class:Tx_MyExtension_ViewHelpers_Link_TypolinkViewHelper maybe not loaded or no autoloader? What's wrong? – user2310852 Feb 09 '15 at 08:28
  • Make sure the ViewHelper in your extension is located in the directory "Classes\ViewHelpers\Link" and also make sure you change the namespace in the ViewHelper file to match the namespace of your extension. – derhansen Feb 09 '15 at 09:24
  • It won't work at my piBase-Extension. typo3conf/ext/ift_modules/Classes/Link/TypolinkViewHelper.php - I change the namespace at the ViewHelper from namespace TYPO3\CMS\Fluid\ViewHelpers\Link; to : namespace IFT\ift_modules\Link\ViewHelpers; And I try it at my Template with: {namespace ift=Tx_IftModules_ViewHelpers} and {txtLink} - AUTOLOADER ERROR – user2310852 Feb 09 '15 at 10:15
0

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>
user2310852
  • 1,654
  • 1
  • 25
  • 52