TYPO3 Fluid - 模板分页
TYPO3 Fluid - Template Paginate
今天的另一个问题,但我正在修复我的扩展程序中的一些错误,这是最后一个。
我多次遇到这个错误:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #145451971: Supplied file object type TYPO3\CMS\Fluid\ViewHelpers\Widget\PaginateViewHelper must be QueryResultInterface
or ObjectStorage or be an array. | UnexpectedValueException thrown in file /var/www/typo3_src_elts/typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php
也许我应该在数组为空时设置一个条件来显示错误消息,但是在哪里呢?在控制器或模板中?
如果您的变量为 null,则必须在控制器中定义一个空数组,然后才能使用 fluid 访问它。
如果它是一个数组,您可以简单地向模板添加一个条件,以检查它是否为空:
<f:if condition="{array -> f:count()} > 0">
<f:then><!-- pagination --></f:then>
<f:else><!-- do something when empty --></f:else>
</f:if>
您也可以尝试检查变量是否存在:
<f:if condition="{array}">
<f:then><!-- pagination --></f:then>
<f:else><!-- do something when empty --></f:else>
</f:if>
这应该适用于空变量,但我没有检查出来。
今天的另一个问题,但我正在修复我的扩展程序中的一些错误,这是最后一个。
我多次遇到这个错误:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #145451971: Supplied file object type TYPO3\CMS\Fluid\ViewHelpers\Widget\PaginateViewHelper must be QueryResultInterface or ObjectStorage or be an array. | UnexpectedValueException thrown in file /var/www/typo3_src_elts/typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php
也许我应该在数组为空时设置一个条件来显示错误消息,但是在哪里呢?在控制器或模板中?
如果您的变量为 null,则必须在控制器中定义一个空数组,然后才能使用 fluid 访问它。
如果它是一个数组,您可以简单地向模板添加一个条件,以检查它是否为空:
<f:if condition="{array -> f:count()} > 0">
<f:then><!-- pagination --></f:then>
<f:else><!-- do something when empty --></f:else>
</f:if>
您也可以尝试检查变量是否存在:
<f:if condition="{array}">
<f:then><!-- pagination --></f:then>
<f:else><!-- do something when empty --></f:else>
</f:if>
这应该适用于空变量,但我没有检查出来。