There is the one way to build it, I could know, but It's complicated for maintenance, because I may add some new entry by time.

I'm trying to figure out a better way to have entry types related to a section and all sections in dropdown menu. Namely, sections have some same, some different entry types. So, when I click at any entry type at current section page, I get all those related entries to the click. It's more like filter feature, but except filtering on current page, you get redirected to a page with selected entry type's option.

Better to visualize it:

(http://www.dev.craft/ = all entry's types from all sections) = all entries from all sections and entry's types.

(http://www.dev.craft/entryTypeHandle = entryTypeHandle from all sections) = entries from all sections and entryTypeHandel.

(http://www.dev.craft/sectionHandle/entryTypeHandle) = entries from sectionHandle and entryTypeHandle

It is hard to read. You're welcome for question's comments, if anything unclear.

1 Answer 1


The only thing I can think of off the top of my head is create custom routes in a plugin dynamically generated from your entryTypes, sectionHandles, and sectionHandle/entryTypes and then point them all to the same template, which would then either display the entries directly (via twig) or dynamically include a corresponding template, based on the handle.

Something like the following perhaps? Completely untested.

public function registerSiteRoutes() {

    // array to store routes
    $routes = [];

    // get all section and entryType handles
    foreach(craft()->sections->getAllSections() as $section)
        // add '/sectionHandle' routes
        $sectionHandle = $section->handle;
        $routes[$sectionHandle] = array('_dynamicTemplates/routeHandler.html');

        foreach($section->getEntryTypes() as $entryType)
            // add '/entryTypeHandle' routes
            $entryTypeHandle = $entryType->handle;
            $routes[$entryTypeHandle] = array('_dynamicTemplates/routeHandler.html');

            // add '/sectionHandle/entryTypeHandle' routes
            $routes[$sectionHandle.'/'.$entryTypeHandle] = array('_dynamicTemplates/routeHandler.html');

    return $routes;


The one thing I don't know is if 'registerSiteRoutes()' gets called on every request, or only once when the plugin gets installed. If not, then you may also need to call it directly from an 'init()' method (or maybe just anytime an entry is saved - so it doesn't get fired on every request).

public function init() {

The template would then grab the segments, perform an ECM search, and display results (or include a dynamic template based on the segments). Note: you might need to add an 'all' (or something else) to the solo 'entryTypeHandle' routes if there is any chance that your sectionHandle and entryType handles are the same. (i.e. '/all/entryTypeHandle').

In theory anyway — the whole thing might not work also. Be interested to hear how it goes.

Note: there also may be some problems with my routes array. I've never tried creating a dynamic route to a template in this way (might need to explicitly add '/templates/'). If anyone sees a problem please feel free to edit the answer or leave a comment. Thanks.

Update: I see a potential problem. See this answer for possible solution. Not sure how to integrate it as part of the answer though. Perhaps send all requests to a controller action, and render the template from there. May have to leave it to you to try and resolve for now — sorry about that.

  • I'd love to test it, if I would have any experience building a plugin in Craft. Have never did that, so I'd be struggling over that first and than I could proceed to the test. Thank you for your answer, We can leave it open, till it gets solved. Commented Apr 9, 2015 at 7:24
  • A great starting place for developing your own plugin is to use a plugin template like BusinessLogic, which provides an empty plugin framework complete with inline documentation, etc. Commented Apr 10, 2015 at 2:13
  • Btw... just a thought, but have you thought about using categories or some other device for creating the kind of cross-referenced structure that your looking for? Seems like a much easier way to do it, and shouldn't require the use of a plugin + more flexible, etc. Commented Apr 10, 2015 at 2:18
  • I may get back to start learning plugin way in Craft, but after I finish, What I've started. And thank you for pointing me to BusinessLogic. Commented Apr 10, 2015 at 8:04
  • Yes, I though about categories. But I also have considered the way I'm using now. It's more appropriate to What I need. Commented Apr 10, 2015 at 8:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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