? page_title_w_tax.patch
Index: page_title.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.install,v
retrieving revision 1.10
diff -u -p -r1.10 page_title.install
--- page_title.install	2 May 2008 16:29:11 -0000	1.10
+++ page_title.install	5 Jan 2009 09:11:05 -0000
@@ -32,4 +32,24 @@ function page_title_uninstall() {
   foreach (node_get_types('names') AS $type => $name) {
     variable_del("page_title_display_$type");
   }
+}
+
+/**
+ * Changes the nid column to id and adds a new column for type 
+ * for integration with views, panels, taxonomy, etc
+ *
+ * Implementation of hook_update_N().
+ */
+function page_title_update_3() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysqli':
+    case 'mysql':
+      $ret[] = update_sql('ALTER TABLE {page_title} CHANGE nid id INT;');
+      $ret[] = update_sql('ALTER TABLE {page_title} ADD COLUMN type VARCHAR(32) NOT NULL DEFAULT "node" FIRST;');
+      $ret[] = update_sql('ALTER TABLE {page_title} DROP PRIMARY KEY;');
+      $ret[] = update_sql('ALTER TABLE {page_title} ADD PRIMARY KEY (type,id);');
+      break;
+  }
+  return $ret;
 }
\ No newline at end of file
Index: page_title.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.module,v
retrieving revision 1.18
diff -u -p -r1.18 page_title.module
--- page_title.module	2 May 2008 16:34:55 -0000	1.18
+++ page_title.module	5 Jan 2009 09:11:05 -0000
@@ -220,20 +220,39 @@ function page_title_form_alter(&$form, $
 function page_title_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   switch ($op) {
     case 'update':
-      db_query("DELETE FROM {page_title} WHERE nid = %d", $node->nid);
-      // fallthrough to insert intentional!
     case 'insert':
-      if (isset($node->page_title) && strlen(trim($node->page_title)) > 0) {
-        db_query("INSERT INTO {page_title} VALUES (%d, '%s')", $node->nid, $node->page_title);
-      }
+      _page_title_set('node', $node->nid, $node->page_title);
       break;
 
     case 'delete':
-      db_query('DELETE FROM {page_title} WHERE nid = %d', $node->nid);
+      _page_title_delete('node', $node->nid);
       break;
 
     case 'load':
-      return array('page_title' => page_title_node_get_title($node->nid));
+      return array('page_title' => _page_title_get('node', $node->nid));
+  }
+}
+
+/**
+ * Implementation of hook_taxonomy().
+ */
+function page_title_taxonomy($op, $type, $object = NULL) {
+  if ($type == 'term') {
+    $id = $object['tid'];
+  }
+  else {
+    return;
+  }
+
+  switch ($op) {
+    case 'delete':
+      _page_title_delete($type, $id);
+      break;
+
+    case 'insert':
+    case 'update':
+      _page_title_set($type, $id, $object['page_title']);
+      break;
   }
 }
 
@@ -247,12 +266,20 @@ function page_title_get_title() {
   $display_options = variable_get('page_title_display', array());
   $node = ((arg(0) == 'node') && (is_numeric(arg(1)))) ? node_load(arg(1)) : NULL;
   
+  $return = strip_tags(drupal_get_title());
+
   if ($display_options[$node->type] && !empty($node->page_title)) {
-    return check_plain(strip_tags($node->page_title));
-  }
-  else {
-    return strip_tags(drupal_get_title());
+    $return = check_plain(strip_tags($node->page_title));
   }
+  else if (arg(0)=='taxonomy' && arg(1)=='term' && is_numeric(arg(2)) && variable_get('page_title_tax', FALSE)) {
+    $tax_page_title = _page_title_get('term', arg(2));
+    if ($tax_page_title != '') {
+      $return = $tax_page_title;
+    }
+  } 
+  
+  return $return;
+  
 }
 
 
@@ -267,7 +294,7 @@ function page_title_get_title() {
  *   string The node's page title.
  */
 function page_title_node_get_title($nid) {
-  return db_result(db_query('SELECT page_title FROM {page_title} WHERE nid = %d', $nid));
+  return _page_title_get('node', $nid);
 }
 
 
@@ -354,3 +381,24 @@ function page_title_token_list($type = '
   
   return $tokens;
 }
+
+
+/*
+ * New get / set / delete functions for titles on other types of pages
+ */
+
+function _page_title_get($type = 'node', $id){
+  $result = db_result(db_query('SELECT page_title from {page_title} WHERE type = "%s" AND id = %d', $type, $id));
+  return $result;
+}
+
+function _page_title_set($type = 'node', $id = 0, $title = ''){
+  if ($row = db_result(db_query('SELECT page_title from {page_title} WHERE type = "%s" AND id = %d', $type, $id))){
+    db_query("DELETE FROM {page_title} WHERE type = '%s' AND id = %d", $type, $id);
+  }
+  db_query("INSERT INTO {page_title} (id, page_title, type) VALUES (%d, '%s', '%s')", $id, $title, $type);
+}
+
+function _page_title_delete($type = NULL, $id = 0){
+  db_query("DELETE FROM {page_title} WHERE type = '%s' AND id = %d'", $type, $id);
+}
\ No newline at end of file
