Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-873

Contact View and Edit Screens can be customized by contact sub-types


    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: None
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:


      We need the ability to over-ride the default view and edit templates for contacts to support use cases like Quest - Student, Jurisdiction, etc.

      A new column has been added to civicrm_contact - contact_sub_type - which will allow this over-ride.

      The rule for determining which template to render for "view" is:

      • If contact_sub_type NOT NULL - check for $contact_sub_type.tpl in Contact/Page/View.
      • If not present, check for $contact_type.tpl
      • If not present, use Basic.tpl

      Rule for which template to use for "edit" is similar (except default is Edit.tpl)

      Adding new contact records for a contact sub type
      We also need to provide a mechanism for creating NEW records of a given contact_sub_type. For this version, folks who want to link to "Add..." form for a contact_sub_type (that has a custom template) will do this by adding cst=$contact_sub_type to the query string.

      Example: If I want to use a contact_sub_type called "Jurisdiction" which is a sub-type of "Organization", I would create the following templates:

      • templates/CRM/Contact/Form/Jurisdiction.tpl
      • templates/CRM/Contact/Page/View/Jurisdiction.tpl

      ... and I would invoke "New Jurisdiction" with the following link: <cms_URL>/civicrm/contact/add?ct=Organization&cst=Jurisdiction

      Coding Tasks:
      1. Add logic to check for both ct=(Individual, Organization or Household) & cst=(string) in query string when invoke path is civicrm/contact/add
      2. If found, validate that cst value IS a string and is "safe" and is 64 char or less (length of civicrm_contact.contact_sub_type column)
      3. If valid, check for corresonding "edit template" file - e.g. templates/CRM/Contact/Form/$contact_sub_type.tpl
      4. If custom template found, invoke requested Form class (e.g. "Individual", "Organization"...) but with customized sub-type template.
      5. Also, modify setTitle in Contact/Form/Edit.php to use contact_sub_type in title (e.g. "New Jurisdiction" appears at top of page).
      6. If no custom template found (in expected path/name) - then just invoke standard form/tpl for the passed contact type (ct=)




            • Assignee:
              deepak Deepak Srivastava
              dgg David Greenberg
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: