function taxonomy_breadcrumb_taxonomy in Taxonomy Breadcrumb 7
Same name and namespace in other branches
- 5 taxonomy_breadcrumb.module \taxonomy_breadcrumb_taxonomy()
- 6 taxonomy_breadcrumb.module \taxonomy_breadcrumb_taxonomy()
Checks to see if a vocabulary or term is being updated and makes the necessary changes in the taxonomy_breadcrumb database tables.
6 calls to taxonomy_breadcrumb_taxonomy()
- taxonomy_breadcrumb_taxonomy_term_delete in ./
taxonomy_breadcrumb.module - Implements hook_taxonomy_term_delete().
- taxonomy_breadcrumb_taxonomy_term_insert in ./
taxonomy_breadcrumb.module - Implements hook_taxonomy_term_insert().
- taxonomy_breadcrumb_taxonomy_term_update in ./
taxonomy_breadcrumb.module - Implements hook_taxonomy_term_update().
- taxonomy_breadcrumb_taxonomy_vocabulary_delete in ./
taxonomy_breadcrumb.module - Implements hook_taxonomy_vocabulary_delete().
- taxonomy_breadcrumb_taxonomy_vocabulary_update in ./
taxonomy_breadcrumb.module - Implements hook_taxonomy_vocabulary_update().
File
- ./
taxonomy_breadcrumb.module, line 174 - The taxonomy_breadcrumb module generates taxonomy based breadcrumbs on node pages and taxonomy/term pages. The breadcrumb trail takes on the form: [HOME] >> [VOCABULARY] >> TERM >> [TERM] ...
Code
function taxonomy_breadcrumb_taxonomy($op, $type, $object = NULL) {
if ($type == 'taxonomy_vocabulary' || $type == 'term') {
// Include the .inc file with all helper functions.
module_load_include('inc', 'taxonomy_breadcrumb');
// Set variables to used in query to reflect if vocabulary or term is being updated.
if ($type == 'taxonomy_vocabulary') {
$table = 'taxonomy_breadcrumb_vocabulary';
$key_type = 'vid';
$old_path = _taxonomy_breadcrumb_get_vocabulary_path($object->vid);
}
elseif ($type == 'term') {
$table = 'taxonomy_breadcrumb_term';
$key_type = 'tid';
$old_path = _taxonomy_breadcrumb_get_term_path($object->tid);
}
$key = isset($object->{$key_type}) ? $object->{$key_type} : NULL;
switch ($op) {
case 'insert':
case 'update':
$new_path = isset($object->taxonomy_breadcrumb_path) ? $object->taxonomy_breadcrumb_path : NULL;
// Only modify database when the object has the 'taxonomy_breadcrumb_path' field
if (!is_null($new_path)) {
// Delete the record from taxonomy_breadcrumb_vocabulary or taxonomy_breadcrumb_term.
if (drupal_strlen($new_path) == 0 && $old_path !== NULL) {
db_delete($table)
->condition($key_type, $key)
->execute();
}
elseif (drupal_strlen($new_path) != 0 && $old_path != NULL) {
db_update($table)
->fields(array(
'path' => $new_path,
))
->condition($key_type, $key)
->execute();
}
elseif (drupal_strlen($new_path) != 0 && $old_path == NULL) {
db_insert($table)
->fields(array(
$key_type => $key,
'path' => $new_path,
))
->execute();
}
}
break;
case 'delete':
db_delete($table)
->condition($key_type, $key)
->execute();
break;
}
}
}