CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Customizing header when viewing a contact
Pages: [1]

Author Topic: Customizing header when viewing a contact  (Read 616 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Customizing header when viewing a contact
January 31, 2012, 10:07:56 am
I would like to customize the screen at /civicrm/contact/view?reset=1&cid=1234   so that in the title includes city and state in addition to the display name.   If the display name of the contact is "Joe's Flower Shop", then I want to alter the title area to be "Joe's Flower Shop (Chicago, IL) " 

I have looked at modifying the template "CRM/Contact/Page/View/Summary.tpl" and also looked at the hook to modify this screen. But both seem to only deal with the area below the "Actions" button/ribbon.

The HTML element around this item is <h1 class=title>

Any ideas on how to do this?
« Last Edit: January 31, 2012, 10:09:48 am by Sarah Gladstone »
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Customizing header when viewing a contact
January 31, 2012, 11:31:56 am
You can do this in your theme, either in template.php or maybe in page.tpl.php. Or you can use jQuery to do it: http://civicrm.org/blogs/hershel/how-customize-civicrm-pages-jquery
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Customizing header when viewing a contact
February 02, 2012, 03:01:09 pm
Hi Sarah,

I didn't think of this when we talked the other day, but if you're interested in using hooks for this, try pageRun().  This page is named CRM_Contact_Page_View_Summary, and you can test for the page name with code like this:
Code: [Select]
if($page->getVar('_name') == 'CRM_Contact_Page_View_Summary') { ... }
In Drupal, this title is set with drupal_set_title(). Within your hook, you can get the full existing title with drupal_get_title(). 

You'll need to query the database for the city and state, but you can get the contact ID from the $page object itself, with $page->getVar('_contactId').

So something like this will probably do the job:
Code: [Select]
function example_civicrm_pageRun($page) {
  if($page->getVar('_name') == 'CRM_Contact_Page_View_Summary') {

    $contact_id = $page->getVar('_contactId');

    // use API to get $city and $state
    // you may want to set $comma dynamically depending on whether you have both $city and $state
    // ...
 
    // set the title to the new value
    $current_title = drupal_get_title();
    drupal_set_title($current_title . " ($city{$comma}$state)"

  }
}

I'm pretty sure that will do what you need, though the code's untested of course.

Best luck -- and sorry I didn't think of it sooner.

- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Customizing header when viewing a contact

This forum was archived on 2017-11-26.