Steven G
Steven G

Reputation: 45

TYPO3 Fluid - Template Paginate

Another question for today, but I'm fixing some errors in my extension, and that's the last one.

I had this error many times:

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

Maybe I should put a condition when the array is null to display an error message, but where? in controller or template?

Upvotes: 0

Views: 432

Answers (1)

René Pflamm
René Pflamm

Reputation: 3354

If your variable is null, you must define an empty array in the controller befor accessing it with fluid.

If its an array, you can simple add an condition to the template, to check if it's empty:

<f:if condition="{array -> f:count()} > 0">
  <f:then><!-- pagination --></f:then>
  <f:else><!-- do something when empty --></f:else>
</f:if>

You can also try to check if an variable exist:

<f:if condition="{array}">
  <f:then><!-- pagination --></f:then>
  <f:else><!-- do something when empty --></f:else>
</f:if>

This should work for null variables, but I dont checked this out.

Upvotes: 0

Related Questions