dongwei6700
2016-02-17 10:51
浏览 109
已采纳

TYPO3 ViewHelper没有登陆

I am trying to write my own ViewHelper for TYPO3 Fluid

I have the file here:typo3conf/ext/ff_invest/Classes/ViewHelpers/LoremIpsumViewHelper.php

In this file I have this code:

<?php
namespace Originalen\FfInvest\ViewHelpers;
/**
 * This class is a demo view helper for the Fluid templating engine.
 *
 * @package TYPO3
 * @subpackage Fluid
 * @version
 */
class LoremIpsumViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {

/**
 * Renders some classic dummy content: Lorem Ipsum...
 *
 * @param int $length The number of characters of the dummy content
 * @validate $length IntegerValidator
 * @return string dummy content, cropped after the given number of characters
 * @author Lorem Ipsum <lorem@example.com>
 */
public function render($length) {
    $dummyContent = 'Lorem ipsum dolor sit amet.';
    return substr($dummyContent, 0, $length);
}
}

In my template file List.html I have

{namespace blog=Originalen\FfInvest\ViewHelpers}

in the top of the file and

<blog:LoremIpsum length="5" />

in the f.section part.

But I keep getting this error "Could not analyse class: "Originalen\FfInvest\ViewHelpers\LoremIpsumViewHelper" maybe not loaded or no autoloader".

I guess there is a misspelling somewhere. But I can't find it.

The namespace is the same as in the other files of the extension.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试为TYPO3流体编写自己的ViewHelper </ p>

我有 这里的文件:typo3conf / ext / ff_invest / Classes / ViewHelpers / LoremIpsumViewHelper.php </ p>

在这个文件中我有这段代码:</ p>

   &lt;?php 
namespace Originalen \ FfInvest \ ViewHelpers; 
 / ** 
 *此类是Fluid模板引擎的演示视图助手。
 * 
 * @package TYPO3 
 * @subpackage Fluid 
  * @version 
 * / 
class LoremIpsumViewHelper扩展Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
 
 / ** / n *渲染一些经典的虚拟内容:Lorem Ipsum ... 
 * 
 * @param int $ length字符数 虚拟内容
 * @validate $ length IntegerValidator 
 * @return字符串虚拟内容,在给定数量的字符后裁剪
 * @author Lorem Ipsum&lt; lorem@example.com&gt; 
 * / 
 nublic公共函数渲染 ($ length){
 $ dummyContent ='Lorem ipsum dolor sit amet。'; 
返回substr($ dummyContent,0,$ length); 
} 
} 
 </ code> </ pre>  
 
 

在我的模板文件List.html中我有</ p>

  {namespace blog = Originalen \ FfInvest \ ViewHelpers} 
 </ code> </ pre>  
 
 

位于文件顶部,</ p>

 &lt; blog:LoremIpsum length =“5”/&gt; 
 </ code> </ pre  > 
 
 

在f.section部分。</ p>

但我一直收到此错误“无法分析类:”Originalen \ FfInvest \ ViewHelpers \ LoremIpsumViewHelper“可能未加载 或者没有自动加载器“。</ p>

我想某处有拼写错误。 但是我找不到它。</ p>

命名空间与扩展名的其他文件相同。</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题