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!


/**
 * 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'");
}

Comments

dman’s picture

erm, that's "since Drupal 4.5" fwiw...

mlncn’s picture

Looks nice! Care to create a patch? I will commit it.

benjamin, Agaric Design Collective

dman’s picture

Title: How about doing it with local tabs? !! » Edit term and gallery via local tabs, plus menu and alias fields on edit term form
StatusFileSize
new32.7 KB
new26.86 KB
new15.84 KB

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.

dman’s picture

Category: support » feature
Status: Active » Needs review
dman’s picture

StatusFileSize
new16.16 KB

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.

mlncn’s picture

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:

UPDATE: With a patch from new co-maintainer Dan Morrison (dman), edit_term will become 75% more Drupaly as it provides edit and view tabs directly on taxonomy listing pages.

The main features left to look at are how automatically to find and display itself for uses of taxonomy that override the taxonomy/term menu structure. We've hardcoded it for image, and for place, but it would be nice to read off the same table taxonomy redirect manipulates to make this work for all well-coded modules and custom taxonomy_redirect overrides.

benjamin, Agaric Design Collective

dman’s picture

Version: 5.x-0.5-beta » 5.x-1.0
Status: Needs review » Fixed

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.

dman’s picture

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.

dman’s picture

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.

mlncn’s picture

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!)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.