Commit 65f8a993 authored by Michael Haggerty's avatar Michael Haggerty

adding theme templating to contacts, correcting issue with reports

parent 10974a55
<?php
// contact.tpl.php
// generic contact display template
?>
<div id="contact-<?php print $type . '-' . $cid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if ($view_mode !== 'full'): ?>
<h2<?php print $title_attributes; ?>><a href="<?php print base_path(); ?>crm/contact/<?php print $cid; ?>"><?php print render($contact_data['contact_name']); ?></a></h2>
<?php endif; ?>
<?php if ($view_mode === 'full'): ?>
<?php print render($contact_data); ?>
<?php endif; ?>
</div>
\ No newline at end of file
......@@ -706,19 +706,62 @@ function crm_core_contact_delete_multiple($contact_ids = array()) {
/**
* View a single contact record.
*/
function crm_core_contact_view($contact) {
function crm_core_contact_view($contact, $view_mode = 'full') {
$contact->content = array();
$view_mode = 'full';
$langcode = LANGUAGE_NONE;
field_attach_prepare_view('crm_core_contact', array($contact->contact_id => $contact), $view_mode);
// Add content added by fields.
$contact->content += field_attach_view('crm_core_contact', $contact, $view_mode);
module_invoke_all('entity_view', $contact, 'crm_core_contact', $view_mode, $langcode);
$contact->content += array(
'#theme' => 'contact',
'#contact' => $contact,
'#contact_data' => $contact->content,
'#cid' => $contact->contact_id,
'#type' => $contact->type,
'#view_mode' => $view_mode,
'#language' => $langcode,
);
$build = $contact->content;
unset($contact->content);
return $build;
return $contact->content;
}
/**
* Implementation of hook_theme
*/
function crm_core_contact_theme($existing, $type, $theme, $path) {
return array(
'contact' => array(
'variables' => array('contact' => null, 'type' => null, 'contact_data' => null, 'cid' => null, 'view_mode' => null),
'template' => 'contact'
),
);
}
/**
* Process variables for contact.tpl.php
*
* This function simply adds template suggestions for various
* contact types.
*
*/
function template_preprocess_contact(&$variables) {
// hide the label on the name field, when we are looking at something
// besides a full view mode
if($variables['view_mode'] !== 'full'){
$variables['contact_data']['contact_name']['#label_display'] = 'hidden';
}
// add classes based on the type of contact
$variables['classes_array'][] = 'contact-' . $variables['type'];
// add template suggestions
$variables['theme_hook_suggestions'][] = 'contact__' . $variables['type'];
}
/**
* Title callback for a contact.
......
......@@ -39,8 +39,8 @@ function crm_core_report_menu() {
/**
* Provides a listing of all reports registered for CRM Core
*/
$items['crm/reports'] = array(
'title' => 'Reports',
$items['crm/report'] = array(
'title' => 'CRM Reports',
'page callback' => 'crm_core_report_list',
'access arguments' => array('view crm report index'),
'type' => MENU_LOCAL_TASK,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment