Edit term and gallery via local tabs, plus menu and alias fields on edit term form
dman - February 25, 2008 - 14:15
| Project: | Edit term |
| Version: | 5.x-1.0 |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
How about this? Totally Drupally, no?

Here's the relevant code, I just worked it into my personal 'tweaks' module that I've had running since Drupal 5 containing useful UI changes. I came looking for a project to share it with - yours is the first in alphabetical order ... but I know there's a tweaks module out there.
This adds the needed tabs to both taxonomies and image galleries. and uses $destination to complete the loop and take you back to the start! Works with pathauto and taxonomy_context so far ... not sure about taxonomy_menu. I hate taxonomy_menu ....
Anyway, thought I'd share!
<?php
/**
* Hook Implimentation
*/
function tweakui_menu($may_cache) {
$items = array();
/* other bits removed */
if (arg(0) == 'image' && arg(1) == 'tid') {
// Add an edit tab to gallery pages for easy access
// Need a default view for the advanced tab to show :-/
$items[] = array(
'path' => 'image/tid/'. arg(2) .'/view',
'title' => t('View'),
'weight' => 0,
'type' => MENU_DEFAULT_LOCAL_TASK
);
$items[] = array(
'path' => 'image/tid/'. arg(2) .'/edit',
'title' => t('Edit term'),
'callback' => 'tweakui_edit_taxonomy_term',
'callback arguments' => array(arg(2)),
'access' => node_access('administer images'),
'weight' => 1,
'type' => MENU_LOCAL_TASK
);
}
if (arg(0) == 'taxonomy' && arg(1) == 'term') {
// Add an edit tab to taxonomy pages for easy access
// Need two default views - parent and default - for the advanced tab to show :-/
// There may be an easier way
$items[] = array(
'path' => 'taxonomy/term/'. arg(2) ,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => 'taxonomy/term/'. arg(2) .'/view' ,
'title' => t('View'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'access' => TRUE,
);
$items[] = array(
'path' => 'taxonomy/term/'. arg(2) .'/edit' ,
'title' => t('Edit term'),
'callback' => 'tweakui_edit_taxonomy_term',
'callback arguments' => array(arg(2)),
'access' => node_access('administer taxonomy'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);
}
return $items;
}
/**
* Redirect the extra tab to the taxonomy edit page.
*/
function tweakui_edit_taxonomy_term($tid) {
$term = taxonomy_get_term($tid);
$_REQUEST['destination'] = 'taxonomy/term/'. $tid;
if ($term) {
drupal_set_title(t("Editing %term", array('%term' => $term->name)));
return taxonomy_admin_term_edit($tid);
}
else {
return t("Failed to load term");
}
}
/**
* Implementation of hook_install().
*/
function tweakui_install() {
// ensure this always runs AFTER menu.module and the rest of core has done its forms;
db_query("UPDATE {system} SET weight = 3 WHERE name = 'tweakui'");
}
?>| Attachment | Size |
|---|---|
| edit_term.gif | 16.3 KB |

#1
erm, that's "since Drupal 4.5" fwiw...
#2
Looks nice! Care to create a patch? I will commit it.
benjamin, Agaric Design Collective
#3
Here you go.
The patch is bigger than the module, so it's almost a total replacement.
I left the block method in there however. You may find in unneccessary now.
I'll tell you, I've been using this for a week now, with a client, and it's so much more efficient than the normal 20-click we'd need to normally - spot a typo, change the term def, edit the menu, find and fix an alias for it!
I'll attach the full module zip also.

#4
PING!
We're coming to join you!
#5
Can we roll this?
I don't mind going in as co-maintainer.
Here's a small update from the above with some fixes for image galleries - using the image/tid/n path where appropriate, not the taxonomy/term/n one.
#6
Welcome aboard, dman! You now have CVS access, which I think is the definition of co-maintainer (can't find any other additional settings).
I haven't even had a chance to test this yet, but certainly roll it into a dev release. Thanks a lot for this, I'm sorry I've been completely swamped with non-taxonomy stuff.
I've added this text to the top of the module page:
benjamin, Agaric Design Collective
#7
Tagged, numbered, released.
New number as the change is so big.
Skipping beta/dev as beta is boring - there's not a lot that can go wrong (famous last words). I think this is a fun project/improvement that needs a bit of publicity.
I also revised the overview text a bit (mostly to make it read snappier in the teaser list) + added a picture.
#8
Finding it hard to make this release get listed on the project page. Maybe it's a time thing before the tarball is ready. It may appear overnight.
#9
Yeah, as you see, the release still isn't listing. I tagged it linearly but didn't branch it (branches are frustrating) but that shouldn't have been a problem.
Could it be the ownership? Odd.
#10
I know another maintainer had the same issue with her new module. (In fact, it's still not listed on the project page.)
Same deal as for us-- it's just not available on the "manage releases" page to be made official/recommended. Worth filing an issue?
(For now I've linked in the intro text, which can be trimmed more if you want!)
#11
Automatically closed -- issue fixed for two weeks with no activity.