Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 - Add a location filter to the events overview page #17

Open
wants to merge 1 commit into
base: assignment/11
Choose a base branch
from

Conversation

luca-rath
Copy link
Contributor

@luca-rath luca-rath commented Jul 7, 2020

Add a location filter to the events overview page

Goal

After adding an association between our Location entity and our Event entity in the last assignment, we can
now easily query events for a specific location. We want to make use of this by adding a location filter to the
events overview page of our website.

Steps

  • Create a new content controller App\Controller\EventOverviewController
  • Remove the events property from the event_overview template
  • Use the newly created App\Controller\EventOverviewController in your event_overview template
  • Use the EventRepository to load events in your EventOverviewController
  • Use the LocationRepository to load locations in your EventOverviewController
  • Pass the loaded locations and events to your Twig template
  • Render a form with a location dropdown in your templates/events/index.html.twig
  • Add a filterByLocationId method to your App\Repository\EventRepository
  • Call the filterByLocationId method with the submitted value in your EventOverviewController

Hints

More Information

Links

@alexander-schranz alexander-schranz added the assignment Pull request for a assignment solution label Sep 23, 2020
@niklasnatter niklasnatter force-pushed the assignment/12 branch 2 times, most recently from e3ef375 to 89eb451 Compare September 23, 2020 10:47
@niklasnatter niklasnatter force-pushed the assignment/12 branch 2 times, most recently from 72306bd to f921a74 Compare October 23, 2020 09:14
@niklasnatter niklasnatter force-pushed the assignment/12 branch 3 times, most recently from 8b288bc to e33a7bb Compare October 23, 2020 15:14
@niklasnatter niklasnatter force-pushed the assignment/12 branch 2 times, most recently from 1af5785 to 7e174f3 Compare February 16, 2021 14:23
@costeaalex
Copy link

Guys, is this supposed to work properly because I cannot get it to work at all and I am an experienced dev. I tried this https://docs.sulu.io/en/2.4/cookbook/custom-controller.html but to no avail and am getting
Cannot autowire argument $structure of "App\Controller\Website\EventOverviewController::indexAction()": it references interface "Sulu\Component\Content\Compat\StructureInterface" but no such service exists. Did you create a class that implements this interface?

@alexander-schranz
Copy link
Member

alexander-schranz commented Apr 12, 2022

@costeaalex the Structure is no service this is a request attribute set by the content route provider. The error you are experience is mostly done if you try to register a route for a content controller, but content controller do not have a route as they are called by the dynamic route provider, which calls the controller based on saved pages and the pages template.

@costeaalex
Copy link

@costeaalex the Structure is no service this is a request attribute set by the content route provider. The error you are experience is mostly done if you try to register a route for a content controller, but content controller do not have a route as they are called by the dynamic route provider, which calls the controller based on saved pages and the pages template.

I figured it out eventually, thanks. I think what would be helpful though is to offer the preferred solution to these problems as well so that people less experienced manage to get through it in a reasonable time span ;). Thanks for the input. You will probably be hearing from me for some consultancy and if we adopt the CMS we will contribute :P.

@alexander-schranz
Copy link
Member

@costeaalex If there is anything we can improve in the documentation, we are happy for any pul request there: https://docs.sulu.io/en/2.4/cookbook/custom-controller.html. Happy to hear you give sulu a try, you can reach us over our website or our slack channel for any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assignment Pull request for a assignment solution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants