Community & Support

Help me please!!!! How can i display customer name in type field on menu "Home> Administer>Content management>Content"

my screen1 : http://bananamax.net/drupal/01.png
my screen2 : http://bananamax.net/drupal/02.png

How can i display customer name from screen2 to screen1

mycode

<?php
// $Id$
/**
* @file
* Module for fetching data from http://www.mysite.com
* This module provides block content retrieved from a
* howhost.com Contact import from parallrels
* @see http://www.mysite.com
*/

/**
* แปะติด help
*/
function contact_parallrels_list_help($path, $arg) {
  if ($path == 'admin/help#contact_parallrels_list') {
    $txt = 'นี่เป็นโมดูลที่ใช้ในการโหลด excel จากระบบ pcc ของ parallrels เข้าสู่ระบบ Crm  Drupal ของ !contact_parallrels_url '
      .'ระบบจะทำการแยกชื่อที่อยู่ และเบอร์โทรศัพท์ โดยคงค่า Id เดิมไว้เข้าสู่ฐานข้อมูล';
    $link = l('howhost.com', 'http://www.mysite.com');
    $replace = array(
      '!contact_parallrels_url' => $link
    );
    return '<p>'. t($txt, $replace) .'</p>';
  }
}
/**
* Implements hook_node_info()
*ไป hook สร้างไว้ใน content type
*/
function contact_parallrels_list_node_info() {
  return array(
    'contact_parallrels' => array(
      'module' => 'contact_parallrels_list',
      'name' => t('Contact Parallrels List'),
      'description' => t("เก็บ Contact จาก Parallrels HSPC ที่ ดึงออกมาจาก API เพื่อใช้ในระบบกลาง"),
      'has_title' => true,
      'title_label' => t('Contact Howhost! Name'),
      'email_label' => t('Email'),
      'has_body' => false,
      'body_label' => t('Body'),   
    //'module' => 'biography',
    )
  );
}
/**=====================Form Create=========================**/
function contact_parallrels_list_form(&$node) {
  $type = node_get_types('type', $node);
  // Existing files: title (Biography of) and body (Overview)
  //a.pid,a.name,a.email,a.phone,a.country,a.state,a.dates
    $form['customer_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Customer ID'),
      '#required' => true,
      '#default_value' => $node->customer_pid,
      '#weight' => -5
    );
  if ($type->has_title) {
    $form['customer_name'] = array(
      '#type' => 'textfield',
      '#title' => check_plain($type->title_label),
      '#required' => true,
      '#default_value' => $node->customer_name,
      '#weight' => -5
    );
  }

  // Our custom fields: Dates, Life, Works.
  // (See FAPI docs for specification)
  $form['customer_email'] = array(
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlengh' => 127,
    '#title' => check_plain($type->email_label),
    '#required' => true,   
    '#description' => t("Email of customer"),
    '#default_value' => $node->customer_email,   
  );
  $form['customer_phone'] = array(
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlengh' => 127,
    '#title' => t('Phone'),
    '#required' => true,   
    '#description' => t("Phone of customer"),
    '#default_value' => $node->customer_phone,       
  );
  $form['customer_country'] = array(
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlengh' => 127,
    '#title' => t('Country'),
    '#required' => true,   
    '#description' => t("Country of customer"),
    '#default_value' => $node->customer_country,       
  );    
  $form['customer_state'] = array(
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlengh' => 127,
    '#title' => t('State'),
    '#required' => true,   
    '#description' => t("State of customer"),
    '#default_value' => $node->customer_state,       
  );      
  $form['customer_birth_date'] = array(
    '#type' => 'textfield',
    '#size' => 50,
    '#maxlengh' => 127,
    '#title' => t('Customer Birth Day'),
    '#required' => true,   
    '#description' => t("Birthdate of customer"),
    '#default_value' => isset($node->customer_dates) ? $node->customer_dates : '',
  );
 
  return $form;
}
/**=====================Form Create=========================**/
/**
* Implements hook_perm()
* ไป hook ไว้ใน permission เพิ่อกำหนดสิทธิ์
*/
function contact_parallrels_list_perm() {
  return array(
    'create contact node',
    'edit contact nodes',
    'delete contact nodes',
  );
}
/**
* Implements hook_access()
*
*/
function contact_parallrels_list_access($op, $node, $account) {
  switch ($op) {
  case 'create':
    return user_access('create contact node', $account);
  case 'update':
    return user_access('edit contact nodes', $account);
  case 'delete':
    return user_access('delete contact nodes', $account);
  }
}
// ======================================
// Getting Data:
// ======================================
/**
* Implementation of hook_load()
*/
function contact_parallrels_list_load($node) {
  $result = db_query(
    'SELECT a.customer_pid,a.customer_name,a.customer_email,a.customer_phone,a.customer_country,a.customer_state,a.customer_dates FROM {contact_parallrels_list} a WHERE a.vid = %d',
    $node->vid
  );
  return db_fetch_object($result);
}
/**
* Implementation of hook_view()
*/
function contact_parallrels_list_view($node, $teaser=false, $page=false) {
  $node = node_prepare($node, $teaser); // get it ready for display
 
  $cusid = check_markup($node->customer_pid);
  $name = check_markup($node->customer_name);
  $email = check_markup($node->customer_email);
  $phone = check_markup($node->customer_phone);
  $country = check_markup($node->customer_country);
  $state = check_plain($node->customer_state);     
  $dates = check_plain($node->customer_dates); 
  // Add theme stuff here
  $node->content['contact_parallrels_list_info'] = array(
    '#value' => theme('contact_parallrels_list_info', $cusid, $name, $email,$phone,$country,$state,$dates),
    '#weight' => 1,
  );
 
  return $node;
}
// ======================================
// Theme:
// ======================================
/**
* implements hook_theme()
*/
function contact_parallrels_list_theme() {
  return array(
    'contact_parallrels_list_info' => array(
      'template' => 'contact_parallrels_list_info',
      'arguments' => array(
      'cusid' => null,
        'name' => null,
        'email' => null,
        'phone' => null,
        'country' => null,
        'state' => null,
        'dates' => null,       
      ),
    ),
  );
}
// ======================================
// Database:
// ======================================
/**
* implements hook_insert()
*/
function contact_parallrels_list_insert($node) {
  if(!isset($node->customer_pid)) $node->customer_pid = '';
  if (!isset($node->customer_name)) $node->customer_name = '';
  if (!isset($node->customer_email)) $node->customer_email = '';
  if (!isset($node->customer_phone)) $node->customer_phone = '';
  if (!isset($node->customer_country)) $node->customer_country = '';
  if (!isset($node->customer_state)) $node->customer_state = '';
  if (!isset($node->customer_dates)) $node->customer_dates = '';   
 
  db_query(
    'INSERT INTO {contact_parallrels_list} (vid, nid, customer_pid, customer_name, customer_email, customer_phone, customer_country, customer_state, customer_dates) '
      ."VALUES (%d, %d, %d, '%s','%s','%s','%s','%s','%s')",
    $node->vid,
    $node->nid,
    $node->customer_id,
    $node->customer_name,
    $node->customer_email,
    $node->customer_phone,   
    $node->customer_country,
    $node->customer_state,
    $node->customer_birth_date
  );
}
/**
* implements update_insert()
*/
function contact_parallrels_list_update($node) {
  if ($node->revision) { // Node is new or a revision. See node_example.module.
    contact_parallrels_list_insert($node);
  }
  else {
    db_query("UPDATE {contact_parallrels_list} SET customer_pid= %d, customer_name='%s', customer_email='%s', customer_phone='%s', customer_country='%s', customer_state='%s', customer_dates='%s' "
        ."WHERE vid = %d",
    $node->customer_id,
    $node->customer_name,
    $node->customer_email,
    $node->customer_phone,   
    $node->customer_country,
    $node->customer_state,
    $node->customer_birth_date,
    $node->vid
    );
  }
}
/**
* implements hook_delete()
*/
function contact_parallrels_list_delete($node) {
  db_query('DELETE  FROM {contact_parallrels_list} WHERE nid = %d', $node->nid);
}
/**
* Implements hook_nodeapi()
* This handles deleting revisions.
*/
function contact_parallrels_list_nodeapi(&$node, $op, $teaser, $page) {
  if ($op == 'delete revision')
      db_query('DELETE  FROM {contact_parallrels_list} WHERE vid = %d', $node->vid);
}
/**
เมื่อข้าพเจ้ารักใครซักคนแล้ว ข้าพเจ้าก็คงจะรักเขาทั้งชีวิต เพราะฉะนั้น ไม่เป็นการยุติธรรมดีแล้วหรือ เมื่อเกลียดเขา ข้าพเจ้าก็เกลียดเขาทั้งชีวิตเหมือนกัน
*/

thank you and sorry for my english -_-'

Comments

show your theme tempalte?

can you post your theme template code here?

did you name your theme template properly?

did you clear your theme registry?

contact_parallrels_list_info.

contact_parallrels_list_info.tpl.php

<?php
// $Id$
/**
* Template to display contact_parallrels_list nodes.
*
* Fields available:
* $dates: cleaned plain text string
* $life: cleaned HTML string
* $works: cleaned HTML string
*/
?>

<div class="contact_parallrels_list_info">
  <h2><?php print t('Customer ID');?>:</h2>
  <?php print $cusid;?>
  <h2><?php print t('Name');?>:</h2>
  <?php print $name;?>
  <h2><?php print t('Email');?>:</h2>
  <?php print $email;?>
  <h2><?php print t('Phone');?>:</h2>
  <?php print $phone;?> 
  <h2><?php print t('Country');?>:</h2>
  <?php print $country;?>   
  <h2><?php print t('State');?>:</h2>
  <?php print $state;?>     
  <h2><?php print t('Birth Dates');?>:</h2>
  <?php print $dates;?> 
</div>

contact_parallrels_list.insta

contact_parallrels_list.install

<?php
// $Id$

/**
* Install the Contact Parallrels module
* type.
* @file
*/

/**
* Implementation of hook_install()
*/
function contact_parallrels_list_install() {
  drupal_install_schema('contact_parallrels_list');
}

/**
* Implementation of hook_uninstall()
*/
function contact_parallrels_list_uninstall() {
  drupal_uninstall_schema('contact_parallrels_list');
}

/**
* Implementation of hook_schema()
*/
function contact_parallrels_list_schema() {
  $schema['contact_parallrels_list'] = array(
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),         
      'customer_pid' => array(
      'type' => 'int',
        'unsigned' => TRUE,     
      'not null' => TRUE,
        'default' => 0     
      ),
      'customer_name' => array(
      'type' => 'varchar',
        'length' => 127,      
      'not null' => TRUE,
        'default' => ''
      ),
      'customer_email' => array(
      'type' => 'varchar',
        'length' => 255,      
      'not null' => TRUE,
        'default' => ''
      ),
      'customer_phone' => array(
      'type' => 'varchar',
        'length' => 127,      
      'not null' => TRUE,
        'default' => ''
      ),
      'customer_country' => array(
      'type' => 'varchar',
        'length' => 127,      
      'not null' => TRUE,
        'default' => ''
      ),
      'customer_state' => array(
      'type' => 'varchar',
        'length' => 127,      
      'not null' => TRUE,
        'default' => ''
      ),                                 
      'customer_dates' => array(
        'type' => 'varchar',
        'length' => 127,
        'not null' => TRUE,
        'default' => ''
      ),
    ),
    'indexes' => array(
      'nid' => array('nid'),
    ),
    'primary key' => array('vid'), // Version is primary key. Could do nid, vid.
  );

  return $schema;
}

contact_parallrels_list.info

contact_parallrels_list.info

;$Id$
name = "Contact parallrels list"
description = "List Contact From myweb! customer"
core = 6.x
php = 5.2
version = "0.1 aofiee"
package = APP myweb

thank you!

screen 1 is the default drupal content list

If you are trying to get the customer info to show on screen 1, then in your hook_view you need to set $node->title to value in the customer name variable

<?php
/**
* Implementation of hook_view()
*/
function contact_parallrels_list_view($node, $teaser=false, $page=false) {
 
$node = node_prepare($node, $teaser); // get it ready for display

 
$cusid = check_markup($node->customer_pid);
 
$name = check_markup($node->customer_name);
 
$email = check_markup($node->customer_email);
 
$phone = check_markup($node->customer_phone);
 
$country = check_markup($node->customer_country);
 
$state = check_plain($node->customer_state);    
 
$dates = check_plain($node->customer_dates);
 
// Add theme stuff here
 
$node->content['contact_parallrels_list_info'] = array(
   
'#value' => theme('contact_parallrels_list_info', $cusid, $name, $email,$phone,$country,$state,$dates),
   
'#weight' => 1,
  );

 
// here is where you set node's title
 
    
$node->title = $name;
 
//
 
return $node;
}
?>

now i can fix it in line   if

now i can fix it
in line

  if ($type->has_title) {
    $form['customer_name'] = array(
      '#type' => 'textfield',
      '#title' => check_plain($type->title_label),
      '#required' => true,
      '#default_value' => $node->customer_name,
      '#weight' => -5
    );
  }

"$form['customer_name']" must be "$form['title']" and my database field "name" change to "title"

thank you for help ^_^
sorry for my english

nobody click here