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

AttachmentSize
edit_term.gif16.3 KB

#1

dman - February 25, 2008 - 14:16

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

#2

Benjamin Melançon - February 25, 2008 - 17:42

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

benjamin, Agaric Design Collective

#3

dman - March 8, 2008 - 08:53
Title:How about doing it with local tabs? !!» Edit term and gallery via local tabs, plus menu and alias fields on edit term form

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.

AttachmentSize
edit_term_additions.patch 15.84 KB
edit_term.png 26.86 KB
edit_term-2008-03-08.tgz 32.7 KB

#4

dman - March 10, 2008 - 01:17
Category:support request» feature request
Status:active» needs review

PING!

We're coming to join you!

#5

dman - March 22, 2008 - 05:50

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.

AttachmentSize
edit_term-tabs.patch 16.16 KB

#6

Benjamin Melançon - March 22, 2008 - 11:40

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

#7

dman - March 22, 2008 - 12:31
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.

#8

dman - March 22, 2008 - 12:43

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

dman - March 23, 2008 - 14:25

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

Benjamin Melançon - March 23, 2008 - 14:31

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

Anonymous (not verified) - April 6, 2008 - 14:32
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.