/[drupal]/contributions/modules/taxonomy_title/taxonomy_title.module
ViewVC logotype

Contents of /contributions/modules/taxonomy_title/taxonomy_title.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Wed Apr 29 05:59:00 2009 UTC (6 months, 4 weeks ago) by jenlampton
Branch: MAIN
CVS Tags: DRUPAL-6--1-1, HEAD
Changes since 1.4: +9 -10 lines
File MIME type: text/x-php
#441720: added test for page hook
1 <?php
2 // $Id: taxonomy_title.module,v 1.4 2009/04/29 05:55:09 jenlampton Exp $
3
4 /**
5 * Implementation of hook_help()
6 */
7 function taxonomy_title_help($path, $arg) {
8 switch ($section) {
9 case 'admin/content/taxonomy':
10 return t('<p>Set the page title on your Taxonomy pages.</p>');
11 case 'admin/help#quiz':
12 return t('<p>Set the page title on your Taxonomy pages.</p>');
13 }
14 }
15
16 /**
17 * Implementation of hook_form_alter()
18 */
19 function taxonomy_title_form_alter(&$form, &$form_state, $form_id){
20 if ($form_id == 'taxonomy_form_term'){
21 $title = _taxonomy_title_get_title($form['tid']['#value']);
22 $form['identification']['tax_title'] = array(
23 '#type' => 'textfield',
24 '#title' => t('Taxonomy Page Title'),
25 '#default_value' => $title,
26 '#description' => t('This is the title you will see on your taxonomy page. If left blank, the term name will be used.'),
27 '#weight' => 0,
28 );
29 }
30 }
31
32 /**
33 * Implementation of hook_taxonomy()
34 */
35 function taxonomy_title_taxonomy($op, $type, $array = NULL) {
36 if ($type == 'term') {
37 switch($op){
38 case 'delete':
39 _taxonomy_title_delete_title($array['tid']);
40 break;
41 case 'update':
42 _taxonomy_title_delete_title($array['tid']);
43 _taxonomy_title_insert_title($array['tid'], $array['tax_title']);
44 break;
45 case 'insert':
46 _taxonomy_title_insert_title($array['tid'], $array['tax_title']);
47 break;
48 }
49 }
50 }
51
52 function _taxonomy_title_delete_title($tid){
53 db_query('DELETE FROM {taxonomy_title} WHERE tid = %d', $tid);
54 }
55
56 function _taxonomy_title_insert_title($tid, $title){
57 if ($title != ''){
58 db_query('INSERT INTO {taxonomy_title} VALUES (%d, "%s")', $tid, $title);
59 }
60 }
61
62 function _taxonomy_title_get_title($tid){
63 $title = db_result(db_query('SELECT title FROM {taxonomy_title} WHERE tid = %d', $tid));
64 return $title;
65 }
66
67 /*
68 * Implementtion of hook_preprocess
69 * overrides variables sent to template_preprocess
70 */
71 function taxonomy_title_preprocess(&$variables, $hook) {
72 if ($hook == 'page' && arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && arg(2) > 0) {
73 $title = _taxonomy_title_get_title(arg(2));
74 if ($title){
75 // Sets the meta title.
76 drupal_set_title($title);
77 // Assures the page heading is set.
78 $variables['title'] = drupal_get_title();
79 }
80 }
81 }
82
83
84
85

  ViewVC Help
Powered by ViewVC 1.1.2