Hi,
I'm writing an app where we want optional parts of it to be modular, so the user can install extra functionality on the fly. Adding these items into a navigation menu is fairly easy, however I also thought that if a "module" needs tighter integration into the main app this becomes a problem. In the example below I already have User Accounts which I would like to optionally extend with User Profiles. The idea is to retain separation between the two, ultimately allowing different permissions to be applied, allowing system administrators to amend User Accounts, and office administrators to amend User Profiles.
I have tried adding a user profile module to an already existing users table, whereby the primary key of the new table is also now the foreign key of the users table. In this scenario it would make sense to add this new user profile form as a tab on the existing user form page. Anybody with permissions can view both tabs, on the same page and update information in either tab.
To facilitate a "module" adding it's own tabs to existing tab bars I thought of using a tab table in the database as follows:
[table]
[tr]
[td]field[/td]
[td]type[/td]
[/tr]
[tr]
[td]id[/td]
[td]PK[/td]
[/tr]
[tr]
[td]name[/td]
[td]tab main name - required[/td]
[/tr]
[tr]
[td]title[/td]
[td]tab item name[/td]
[/tr]
[tr]
[td]weight[/td]
[td]weighting to order by[/td]
[/tr]
[tr]
[td]destination[/td]
[td]the view to be partially rendered into the tab[/td]
[/tr]
[tr]
[td]visible[/td]
[td]NULL is default and means true (visible) - or a php expression to determine visibility[/td]
[/tr][/table]
As you can see if the tabs are generated in a view by reading, for example, all the name=>'users' tabs from the table. Ordering it correctly, an addon module can easily insert a tab into another pages code - and hence to the user it makes it look very tightly integrated.
The problem comes from this being done at run time, in order to pass the correct model to the user page, and then passed onto the view created by the new tab, the code in the user controller would have to be changed to facilitate this. This is obviously not desirable as it stops the main point of this functionality whereby we can release a module at a later date and simply add it in, without altering the core code.
The way I could see this working, is if the render partial part of the new tab could go via the new controller for this new module, and hence do the required processing to the new model etc and perform any saving tasks when submitted.
Is it possible to do this? Or am I completely going about this the wrong way?
Any help would be appreciated! Another thought would be to have all the processing code going into the view, but that defeats the purpose of MCV. Sorry for the long-winded question. If it doesn’t make sense I’m happy to clear up any confusion.