[英]TYPO3 ViewHelper is not laded
I am trying to write my own ViewHelper for TYPO3 Fluid 我正在尝试为TYPO3 Fluid编写自己的ViewHelper
I have the file here:typo3conf/ext/ff_invest/Classes/ViewHelpers/LoremIpsumViewHelper.php 我在这里有文件: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 在我的模板文件List.html中,
{namespace blog=Originalen\FfInvest\ViewHelpers}
in the top of the file and 在文件顶部
<blog:LoremIpsum length="5" />
in the f.section part. 在f.section部分中。
But I keep getting this error "Could not analyse class: "Originalen\\FfInvest\\ViewHelpers\\LoremIpsumViewHelper" maybe not loaded or no autoloader". 但是我一直收到此错误“无法分析类:“ Originalen \\ FfInvest \\ ViewHelpers \\ LoremIpsumViewHelper”可能未加载或没有自动加载器”。
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. 名称空间与扩展的其他文件中的名称空间相同。
Change your viewhelper class to use namespaces to extend core classes: 更改viewhelper类以使用名称空间扩展核心类:
class LoremIpsumViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
...
}
TYPO3 7.6 puts the autoload cache into ´typo3temp/autoload/´ - so after deleting this folder new classes are recognized. TYPO3 7.6将自动加载缓存放入“ typo3temp / autoload /”中-因此,在删除此文件夹后,将识别新的类。
btw: the extension typo3_console provides a CLI command to do the same: 顺便说一句:扩展程序typo3_console提供了一个CLI命令来执行相同的操作:
./typo3cms extension:dumpautoload
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.