Közzétéve
2009-07-29 12:53
I'm working on deploying CiviCRM for my kids school website. Part of the project requires us to expose the parent <-> child relationship information on the website and allow parents to edit their child information.
I accomplished this using a combination of civicrm hooks, custom templates, permissioned relationships and custom code in a drupal module. You can access the module and template code here.
The broad steps are:
- Implement hook_civicrm_pageRun for the profile view page (CRM_Profile_Page_Dynamic). Only implement this hook for the specific profile id's you want relationship information. In this case we have two profiles, a Parent Profile (gid=3) and a Student Profile (gid=4)
- The pageRun hook also adds the module's template directory to the smarty include path, so we dont have to set it globally. This also allow multiple modules to append different template directories to the template include path (check the function _sfschool_initialize)
- The hook gets either the parent or the child information using a custom query. We ensure that only permissioned parents can see their child information (in case of some complicated family structures). The queries are relatively simple at this stage, i suspect they will increase in complexity over the next few weeks
- The hook exposes the information gathered from the database to the smarty template
- The custom template (templates/CRM/Profile/Page/3/Dynamic.tpl) uses that information to display the relationship data on the page. I also edited the View.tpl template to eliminate the "Back to Listings" link.
Filed under
Comments
Where can I see a demo website with this code in action?
as such there is no public demo available. You will need to download and install the modules to see it happen. at some point, we might decide to make a public demo available
lobo