Open FlorianBoe opened 1 year ago
This guide is primarily intended for creating your own controllers in the PHPCR context. That is, within the webspace bundle. You will not need this for the most part within the NewsBundle . This is based on a Doctrine entity. Please take a look at the controller of the NewsBundle and copy and adapt it as you need it.
I looked at your controller, I don't think it answers my question. I'm not trying to customize the view of a single news item, I'm trying to access the repository to create a list view.
I am also trying to work out the best way to approach getting news posts to the front end.
I'd like, for example, to be able to do something similar to the following:
In Symfony itself this is pretty straightforward using a Controller extending AbstractController but the Sulu documents don't seem to show much info on standalone controllers that don't have a connection to a specific page template.
Is there perhaps an example project somewhere that has the news integrated into the front end? You mention looking at the controller from the bundle, but what is required to get the autowired services connected as @FlorianBoe mentions?
Hi there!
I have created my own controller for a news overview page and would like to display the latest news paginated here. What is the intended way to access news in the controller?
I have tried the following variant recommended in the SULU documentation to pass additional data to the template, unfortunately without success.
Leads to the following error message:
I have tried to access the repository directly
But get the following error message
Because I am a bit under time pressure in the current project, I have added the following alias in services.xml
Would it make sense to introduce an alias for the repository or is there a better way with SULU that I'm overlooking here?