{"action":"created","issue":{"url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/73","labels_url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/73/comments","events_url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/73/events","html_url":"https://github.com/perfectsense/brightspot-cms/issues/73","id":59157785,"number":73,"title":"Dynamic URL/routes to pages not modelled from a content type","user":{"login":"nickdunn","id":39560,"avatar_url":"https://avatars.githubusercontent.com/u/39560?v=3","gravatar_id":"","url":"https://api.github.com/users/nickdunn","html_url":"https://github.com/nickdunn","followers_url":"https://api.github.com/users/nickdunn/followers","following_url":"https://api.github.com/users/nickdunn/following{/other_user}","gists_url":"https://api.github.com/users/nickdunn/gists{/gist_id}","starred_url":"https://api.github.com/users/nickdunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickdunn/subscriptions","organizations_url":"https://api.github.com/users/nickdunn/orgs","repos_url":"https://api.github.com/users/nickdunn/repos","events_url":"https://api.github.com/users/nickdunn/events{/privacy}","received_events_url":"https://api.github.com/users/nickdunn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-26T22:49:21Z","updated_at":"2015-03-03T21:20:55Z","closed_at":null,"body":"Similar to #70, regarding controller logic and routing.\r\n\r\nI have a Hospital content type, to which Consultants are related. A hospital has a URL /my-hospital and I want to list consultants at /my-hospital/consultants. This listing does not need any bespoke managed content, all dynamic.\r\n\r\nIn something like Rails or Backbone I would have a route such as:\r\n\r\n    /:hospital_name/consultants\r\n\r\nWhere I can then map this pattern onto a controller to render the template that lists consultants for the given hospital.\r\n\r\nDoes Brightspot support dynamic routing such as this, so that CMS-generated URLs directly associated to a model can have child pages auto-generated?"},"comment":{"url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/comments/77037035","html_url":"https://github.com/perfectsense/brightspot-cms/issues/73#issuecomment-77037035","issue_url":"https://api.github.com/repos/perfectsense/brightspot-cms/issues/73","id":77037035,"user":{"login":"hyoolim","id":260663,"avatar_url":"https://avatars.githubusercontent.com/u/260663?v=3","gravatar_id":"","url":"https://api.github.com/users/hyoolim","html_url":"https://github.com/hyoolim","followers_url":"https://api.github.com/users/hyoolim/followers","following_url":"https://api.github.com/users/hyoolim/following{/other_user}","gists_url":"https://api.github.com/users/hyoolim/gists{/gist_id}","starred_url":"https://api.github.com/users/hyoolim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyoolim/subscriptions","organizations_url":"https://api.github.com/users/hyoolim/orgs","repos_url":"https://api.github.com/users/hyoolim/repos","events_url":"https://api.github.com/users/hyoolim/events{/privacy}","received_events_url":"https://api.github.com/users/hyoolim/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T21:20:55Z","updated_at":"2015-03-03T21:20:55Z","body":"Nick, note that for your specific example, you don't really need separate custom controller or routing logic if you use the `**` syntax. Here's a barebones example:\r\n\r\n`Hospital.java`:\r\n\r\n    @Renderer.Paths({\r\n        @Renderer.Path(value = \"hospital.jsp\"),\r\n        @Renderer.Path(context = \"fallback\", value = \"hospital-fallback.jsp\"),\r\n        @Renderer.Path(context = \"consultants\", value = \"hospital-consultants.jsp\")\r\n    })\r\n    public class Hospital extends Content {\r\n\r\n        public String findContext(HttpServletRequest request) {\r\n            switch (request.getPathInfo()) {\r\n                case \"/consultants\" :\r\n                    return \"consultants\";\r\n                default :\r\n                    return \"fallback\";\r\n            }\r\n        }\r\n\r\n        public List<Consultant> findConsultants() {\r\n            return Query.from(Consultant.class).where(\"hospital = ?\", this).selectAll();\r\n        }\r\n    }\r\n\r\n`hospital.jsp`:\r\n\r\n    <cms:render context=\"${content.findContext(pageContext.request)}\" value=\"${content}\" />\r\n\r\n`hospital-consultants.jsp`:\r\n\r\n    <c:forEach var=\"consultant\" items=\"${content.findConsultants()}\"> ... </c:forEach>\r\n\r\nThe reason why we structure things this way is because we typically find that it's difficult to follow routing logic when it's far removed from the model/view, so we tend to have more controller logic in our model than what you might see in some of the other libraries.\r\n\r\nHaving said all that, if you really want to introduce a router or more formal MVC framework, we'd recommend adding Spring or something similar that has much more comprehensive APIs than we could support. Since our default routing is done via a servlet filter that runs last, it's pretty easy to add a filter where you can add custom routing logic before the CMS processes anything."}}