2

i want to use my own controller for fetching some special content. I got a "pageType" called "magazin". I want to fetch the lastest entry of a "magazin" and render the output with the template.

I set the controller in my template definition file.

<view>ClientWebsiteBundle:templates:overview</view>
<controller>SuluWebsiteBundle:Default:index</controller>
<cacheLifetime>2400</cacheLifetime>

is there any example of what the controller should look like? I don't understand what the StructureInterface etc. does.

Patrick
  • 1,562
  • 1
  • 16
  • 33

1 Answers1

1

You can simply inherit from Sulu\Bundle\WebsiteBundle\Controller\WebsiteController. This one offers the renderStructure-method. You can check the Sulu\Bundle\WebsiteBundle\Controller\DefaultController to see how that should be called. In the DefaultController the second parameter is an empty array, just pass whatever you like there, and the data will be merged and passed to the template.

Of course you can also skip the renderStructure method completely, and do whatever you want in the controller. However, stuff like the preview might not be working as expected then.

Daniel Rotter
  • 1,998
  • 2
  • 16
  • 33