Attached patch makes Edit term work with Ubercart catalog terms (catalog/[tid]).

Comments

mlncn’s picture

Thanks for this...

I haven't tried the code, so forgive me if I'm way off, but doesn't Ubercart category use pathauto to give different URL aliases without changing the internal taxonomy path?

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/ubercart/uc...

benjamin, Agaric Design Collective

Eugene Fidelin’s picture

I add this code in function edit_term_menu

if (arg(0) == 'catalog' && is_numeric(arg(1))) {
    // Add an edit tab to taxonomy pages for easy access
    // Need two dummy default items - parent and default - for the advanced tab to show :-/
    // There may be an easier way
    $items[] = array(
      'path' => 'catalog/'. arg(1) .'/'. arg(2) ,
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'catalog/'. arg(1) .'/'. arg(2) .'/view' ,
      'title' => t('View'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'access' => TRUE,
    );
    $items[] = array(
      'path' => 'catalog/'. arg(1) .'/'. arg(2) .'/edit' ,
      'title' => t('Edit Catalog'),
      'callback' => 'edit_term_edit_taxonomy_term',
      'callback arguments' => array(arg(1)),
      'access' => node_access('administer taxonomy'),
      'weight' => 1,
      'type' => MENU_LOCAL_TASK,
    );
  }
OliverColeman’s picture

Version: 5.x-1.0 » 5.x-1.1

Re #1: Nope, it uses its own rendering system for catalog terms: catalog/tid will render term tid using ubercarts theme function, taxonomy/term/tid will render the same term with taxonomys theme function.

jameslov’s picture

Version: 5.x-1.1 » 6.x-1.1
StatusFileSize
new3.82 KB

I'm trying to get this working for Ubercart2 and Drupal6. I added this code to edit_term.module at line 109:

// Add an edit tab to ubercart catalog pages also
$items['catalog/%/view'] = array(
'title' => t('View Catalog Group'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);

$items['catalog/%/edit-term'] = array(
'title' => t('Edit Catalog Group'),
'page callback' => 'edit_term_edit_taxonomy_term',
'page arguments' => array(2),
'access arguments' => array('administer taxonomy'),
'file' => 'taxonomy.admin.inc',
'file path' => drupal_get_path('module', 'taxonomy'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);

And this line at 138 (not sure if its necessary):

$items['catalog/']['type'] = MENU_CALLBACK;

At this point the tabs show up as they should, but when I click on the edit tab I get the 'Failed to load term' error.

The site I'm working on, and a specific example can be viewed here: http://waldenheightsnursery.com/catalog/7/edit-term

If someone could help me get this working, suggest a fix I may have missed, or point out an easier approach, I would greatly appreciate it! I attached the file I was working on.

Thanks in advance,

JamesL

jameslov’s picture

FYI I'm going to turn off the Ubercart catalog and use normal taxonomy with views so that I can use edit term.

edrex’s picture

Title: Ubercart catalog terms » have ubercart use taxonomy pages

it seems that the ideal solution would be to have ubercart use the normal taxonomy term pages, and just override the display. Then any taxonomy links in views, node links etc would go to the catalog. I'm not sure why they didn't do this in the first place. I think I'll try to go this route, theming the taxonomy pages to look like the catalog. Has anyone done this already?

edrex’s picture

I added the following code in my theme to have ubercart render taxonomy pages:

template.php:

 function phptemplate_taxonomy_term_page($tids, $result) {
  return theme_uc_catalog_browse($tids[0]);
}

Note this is a hack:

  • it doesn't handle multiple terms
  • more importantly, it doesn't check the vocabulary, so it will mess up your other vocabularies.

Easy enough to adapt.

edrex’s picture

i wanted to keep using the catalog root page (i'm very lazy) so I add the following to settings.php to rewrite catalog/.* urls to point at the taxonomy term:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
  if (preg_match('|^catalog/(.*)|', $path, $matches)) {
    $path = drupal_get_path_alias('taxonomy/term/'. $matches[1]);
  }
}