Forums | Mahara Community
Add a location to Institution
26 June 2013, 11:38 AM
I am trying to add a location for institutions where the user would select the location and then only the institutions in that location will be shown. The institution would seem to the user as a child element of location but I do not want to do much changes to the database for that.
How would I attempt something like that?
26 June 2013, 1:30 PM
Where do you think to implement this? On the admin interface? In a new block? On the user search page? Currently, a regular user cannot search for institutions. That is only possible on the admin side.
26 June 2013, 3:04 PM
Well, I imagine you would add the user's ability to search by location to this page: http://manual.mahara.org/en/1.7/groups/institution_membership.html ... under the "Request Membership in an Institution" section.
Perhaps a dropdown list of locations, and when you select one it uses JSON to update the page so that the dropdown list of Institutions only shows institutions within that location. (Though, implementing it using JSON would be non-trivial).
You'd also need to add a field to the Institution config page for the institution admin to enter the location, and then a DB field to store that in, and code to put it in and retrieve it from the DB field.
As for the DB side of things, well, it actually would make the most sense to just add a "location" column to the "institution" table (assuming that each institution is in only one location). If you don't want to alter the institution table, or if an institution can span multiple locations, you could create a new table that maps institutions to locations. Maybe call it "institution_location", and it would have an "institutionid" column and a "location" column.
Or, the quick and dirty way to do it, if you don't expect your institutions to change often, just hard-code the list of which institutions are in which locations, in a PHP file.
27 June 2013, 3:51 AM
Hi Aaron, when you say:
add a field to the Institution config page for the institution admin to enter the location, and then a DB field to store that in, and code to put it in and retrieve it from the DB field.
Where is the Institution config page?
27 June 2013, 11:03 AM
I meant the "edit" page for each Institution. This one: http://manual.mahara.org/en/1.7/administration/institutions.html#edit-an-institution
26 June 2013, 11:09 PM
This is on the admin interface. Thanks Kristina
04 July 2013, 2:45 PM
I have added a new column called location to the institution table and included a location element in the element array which is processed by pieform. I am able to enter information in this on the website but the location is not stored in the database.
I have added a few more custom tables and it's the same. I added a dateoffbirth column to the usr table and the date of birth is not being stored, its just zeros.
For the institution table, is there another area to add the new column for it to work? Is it the same for the usr table and why is it only showing zeros, do I need to use a specific type in the pieform element array?
Your help is highly appreciated.