have ubercart use taxonomy pages

Oliver Coleman - April 8, 2008 - 02:18
Project:Edit term
Version:6.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

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

AttachmentSize
edit_term.module.ubercart.diff1.01 KB

#1

agaric - April 16, 2008 - 16:57

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

#2

Eugef - June 11, 2008 - 14:13

I add this code in function edit_term_menu

<?php
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,
    );
  }
?>

#3

Oliver Coleman - January 4, 2009 - 01:19
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.

#4

jameslov - March 22, 2009 - 05:13
Version:5.x-1.1» 6.x-1.1

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

AttachmentSize
edit_term.module.gz 3.82 KB

#5

jameslov - March 30, 2009 - 13:57

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

#6

edrex - July 19, 2009 - 22:37
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?

#7

edrex - July 19, 2009 - 23:22

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

template.php:

<?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.

#8

edrex - July 19, 2009 - 23:21

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]);
  }
}

 
 

Drupal is a registered trademark of Dries Buytaert.