2

In the Entries tab in the Control Panel, I see a list of Sources on the left hand side:

  • All Entries
  • Singles
  • News

When I click on each of these sources the page filters the appropriate results in the body and the URL gets updated appropriately:

  • All Entries => /admin/entries
  • Singles => /admin/entries/singles
  • News => /admin/entries/news

This is nice as I can now send links to other people to a specific sub-section in the sources, with the contents already filtered.

I've compared my code in the source nav to the code on the Entries Element Index page, and they are comparable, including passing the data-handle value to each source. But it's still not working in my Custom Element type. I must be missing something but I haven't yet figured out what.

How do we get this behavior working for custom Element Types?

1

Your plugin has to create those routes — via registerCpRoutes() — to match your desired URL structure.

Routes either trigger a site template or a controller, as described in the Routing docs. (Craft's own internal convention is for CP routes to trigger a controller method, which sets up the request and renders your desired template.)

You can look at Craft's own CP routes for inspiration in setting up your own; they're defined in /app/etc/config/common.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.