【问题标题】:Render Link within Typoscript Controller在 Typoscript 控制器中渲染链接
【发布时间】:2017-10-12 12:58:11
【问题描述】:

我担心这可能是一个插件特定/相关的问题,但也许有一些更有经验的 TypoScript / Extensions 程序员,他们可以给我一个快速提示在哪里查看。

我正在使用图库插件YAG Gallery。出于 SEO 的目的,我希望在 itemList 的上一页和下一页的标题中添加附加链接。

目前我实现了以下目标: 在Classes/Controller/ItemListController.php 中,我在函数“listAction”中添加了以下几行:

$pager = $this->extListContext->getPagerCollection();
$nextLinkUid = $pager->getNextPage();
$prevLinkUid = $pager->getPreviousPage();
$prev = '<link rel="prev" href="' . $prevLinkUid . '">';
$next = '<link rel="next" href="' . $nextLinkUid . '">';
$this->response->addAdditionalHeaderData($prev . PHP_EOL . $next);

有了这个,我在页面的&lt;head&gt; 部分获得了两个额外的标签

<link rel="prev" href="1">
<link rel="next" href="2">

到目前为止,一切都很好——我有一个正确的条目,我有上一个和下一个链接的页面 uid。

有谁知道我怎样才能在这个地方获得实际的链接?就像在 Resources/Private/Partials/Pager/Default.html 中呈现的一样

<f:if condition="{pager.showPreviousLink}">
   <li class="previous">
      <extlist:link.action controller="{controller}" action="{action}" arguments="{extlist:namespace.GPArray(object:'{pagerCollection}' arguments:'page:{pager.previousPage}')}"><span>&lt;</span></extlist:link.action>
   </li>
</f:if>

我必须从控制器调用什么操作来获取链接?

我假设我可能不得不以某种方式使用来自Classes/ViewHelpers/Link/ItemViewHelper.phprender - 但是如何?我不知道如何将语法从 Partial 转换为我可以从控制器中调用的某些语法。

【问题讨论】:

    标签: php seo typo3 typo3-7.6.x typo3-extensions


    【解决方案1】:

    对于任何想知道我是如何解决这个问题的人:

    我没有使用 addAdditionalHeaderData,而是通过流体视图助手直接在部分中添加标题数据:

    https://github.com/YAG-Gallery/yag/pull/116

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-20
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 2016-12-14
      • 1970-01-01
      • 2012-09-13
      • 2020-10-09
      相关资源
      最近更新 更多