3462 Posts in 1065 Topics by 740 members
|Go to End|
12 April 2014 at 2:21am
i habe a general question about a clean way to build a page subtree of a custom controller.
I builded a rather big silverstripe site with a big login area inside the front-end.
Inside this login area users can manage projects. I have around 8 childpages under each projekt like "edit","analyse","export", "statistics" etc.
I solved that one with a very fat controller (2000 Lines until now) which rewrites Menu() and fakes the whole silverstripe page management.
1. This is getting messy
2. I'm bypassing the cms, you can't see any of these pages in the cms. Therefore you can't edit texts unless I add custom fields inside the PageObject of that controller. (which is not an option)
The reason I did this is that every child page needs the particular project Objekt, so I have a variable in between the cms Tree.
Do someone know a better way to do that?
Greets from germany and thanks
13 April 2014 at 10:09am
A controller could have a single responsibility so just move each of the actions out to another controller. You'll need to modify the handleAction method on your Parent controller to create the correct child controller for each action. That would remove a lot of your code from your main controller.
Another option would be to change your structure so that you move the actions to the top level rather than child pages. You could then use page types (so fields are editable in the CMS). The correct project could be passed in by ID like /edit/project/ rather than /project/edit
14 April 2014 at 7:50am
Thanks a lot for you're help. The first approach is absolutely clear.
The second one is not fully clear to me. Normally you have something like /my-area/projects (ProjectsHolder) where you pick a project. Inside project you would be in /my-area/projects/project-bla/edit or /my-area/projects/8/edit
If I would build the pages with page types, I would create a page type for example ProjectEditPage and someone would add this one in the cms under /my-area/projects/ (in page types PersonalAreaPage/ProjectHolder/ProjectEditPage) and pass the ProjectID through the pages.
But I can't understand how edit/project could solve it. Without NestedUrls?
Thanks in advance
|Go to Top|