【问题标题】:Typo3 Fluid: What is the correct way to render flux:flexform.field.wizard.link?Typo3 Fluid:渲染flux:flexform.field.wizard.link的正确方法是什么?
【发布时间】:2013-09-29 10:28:14
【问题描述】:

我正在使用 Typo3 6.1 和 Fluid 模板,使用 fedext.net 工具集。 我有这样定义的内容元素后端模板:

{namespace flux=Tx_Flux_ViewHelpers}
{namespace v=Tx_Vhs_ViewHelpers}
<f:layout name="Content" />
<div xmlns="http://www.w3.org/1999/xhtml"
     xmlns:flux="http://fedext.net/ns/flux/ViewHelpers"
     xmlns:v="http://fedext.net/ns/vhs/ViewHelpers"
     xmlns:f="http://fedext.net/ns/fluid/ViewHelpers">

...

<flux:flexform.object name="item">
    <flux:flexform.field.input name="url">
        <flux:flexform.field.wizard.link />
    </flux:flexform.field.input>
</flux:flexform.object>

然后我像这样在前端渲染它

<f:link.external uri="{section.item.url}">
    {section.item.url}
</f:link.external>

问题是链接后端向导允许用户设置链接,如 http://www.google.com/ _blank - Google 代表 href target css-class title 并最终出现在以下前端 HTML 渲染中:

<a href="http://www.google.com/ _blank - Google">
    http://www.google.com/ _blank - Google
</a>

我想知道是否已经有任何 ViewHelper 允许正确呈现链接小部件数据?或者我应该自己实施一个?我已经检查了这些文档:

我坚持使用第一个,但它比我真正需要的要简单一些。 可能还有一个 ViewHelper 可以按空格字符拆分链接数据,然后我可以渲染链接,但听起来像一个不可靠的解决方法。

【问题讨论】:

    标签: typo3 fluid flux viewhelper fedext


    【解决方案1】:

    简单的答案是,flux 和 fluidcontent 本身并不为它们提供 ViewHelper。

    您必须使用像 this one 这样的外国 ViewHelper。我将它的a variant 添加到 VHS ViewHelper 集合扩展中。与流体核心类似,我们在 VHS 配套扩展中添加了 2 个新的 ViewHelper(v:link.typolink & v:uri.typolink):

    安装后,将命名空间导入到您的模板中,如下所示:

    {namespace v=Tx_Vhs_ViewHelpers}

    并在您的模板中使用它:

    <v:uri.typolink parameter="{parameter: section.item.url}" />

    这应该可以解决问题。

    此外,由于这仅呈现由typolink生成的uri,因此vhs中还有第二个非常相似的ViewHelper可以用来生成链接:

    <v:link.typolink parameter="{parameter: section.item.url}">Beautiful link</v:link.typolink>

    感谢 kimomat 在下面的答案中指出这一点。

    【讨论】:

    【解决方案2】:

    如果我在流体内容主部分(TYPO3 6.2、VHS 1.9.1、流体内容 4.0.0)中呈现示例,则 ViewHelper 仅输出链接 url,不输出链接。

    <p><v:uri.typolink configuration="{parameter: '13', additionalParams: '&print=1', title: 'Follow the link'}">Click Me!</v:uri.typolink></p>
    

    这段代码将呈现:

    <p>/products/?print=1</p>
    

    PageUid 13 是产品页面。 我本来希望有一个标签。

    好的,我明白了。我需要 ViewHelper v:link.typolink:

    <v:link.typolink configuration="{parameter: '13', additionalParams: '&print=1', title: 'Follow the link'}">Click Me!</v:link.typolink>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多