I have a controller file and a twig template but the communication is disturbed. The Exception is:
An exception has been thrown during the rendering of a template ("Error producing an iterator").
Either I still miss something in the controller file or something is wrong with the settings.
My Object is "ArticleCategory" Controller:
namespace AppBundle\Controller;
use Pimcore\Controller\Configuration\ResponseHeader;
use Pimcore\Model\Asset;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Pimcore\Model\DataObject\ArticleCategory;
use Zend\Paginator\Paginator;
class ContentController extends FrontendController
{
public function testroot1Action(Request $request)
{
$articleCategory = new ArticleCategory\Listing();
$articleCategory->setOrderKey('date');
$articleCategory->setOrder('DESC');
$paginator = new Paginator($articleCategory);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(5);
var_dump($paginator);
$this->view->content = $paginator;
}
}
The Twig Template. The Exception comes from my for in loop. The iterate of "content" dosent work:
{% extends 'layout.html.twig' %}
{% block content %}
{{ dump(content)}}
{% for contents in content %}
{{ dump(contents)}}
{% endfor %}
{% block content %}
Is there somthing more to do or is somthing wrong?
it should be :
{% extends 'layout.html.twig' %}
{% block content %}
{% for content in contents %}
// here you have access to a singular content object
{% endfor %}
{% block content %}
Ah no that isnt it! It seems that my Listing is empty!
$articleCategory = new ArticleCategory\Listing();
Hm i will test it later more Thx