Manufacturer and Catalog links don't honor path aliases

Project:Ubercart Contributions
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:patch (needs review)
Description
Project: 
Ubercart

I have pathauto setup to create nice path aliases for taxonomy links, however Ubercart doesn't use them. Instead it creates it's own paths at "manufacturer/#" and "catalog/#/term".

The two attached patches make it so UC checks to see if aliases are registered for the taxonomy terms, defaulting to the current behavior if there isn't an alias.

** UPDATED ** See comment below. Changed to Feature Request, as UC urls should be customizable (either through pathauto or internally).

wazdog's picture
Offline
Joined: 12/11/2007
Juice: 18
Re: Manufacturer and Catalog links don't honor path aliases

Guess I should have thought this through a bit more... I see why UC is using their own urls -- because a custom page is created and UC isn't sending the visitor to the taxonomy listing page.

I still see the fact that you can't customize your manufacturer and catalog urls as a problem, but the fix will be more complicated and require that uc_manufacturer and uc_catalog hook into pathauto to create aliases automatically for their internal urls.

I'll see what I can code up...

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Manufacturer and Catalog links don't honor path aliases
Assigned to:wazdog» Ryan

Thanks for raising the issue... I'd PM Lyle if I were you. I think he's working on the code, too.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Manufacturer and Catalog links don't honor path aliases
Assigned to:Ryan» Lyle

I discovered that using hook_link_alter() works better than hook_term_path because it allows the path module to alias both the taxonomy pages and the catalog pages. The links on the node to the taxonomy terms will be overridden to point to the appropriate catalog page. I debated for a while about that, and I think it's a reasonable thing for the catalog module. Most sites that use the catalog won't be using the taxonomy pages much, so there shouldn't be a lot of confusion.

wazdog's picture
Offline
Joined: 12/11/2007
Juice: 18
Re: Re: Re: Manufacturer and Catalog links don't honor path alia
Assigned to:Lyle» wazdog

How would we use hook_link_alter() in the module? Maybe I'm not understanding the concept... let's use uc_manufacturer as an example:

There are two links in the system for a manufacturer, the taxonomy term link ("taxonomy/term/#" leading to the taxonomy listing page) and the uc_manufacturer link ("manufacturer/#" leading to the UC manufacturer page). My original patch was:

<?php
  $path
= drupal_get_path_alias('taxonomy/term/' . $term->tid);
  if (
$path == ('taxonomy/term/' . $term->tid)){
   
$path = 'manufacturer/'. $term->tid;
  }
  return
$path;
?>

and the idea was to lookup the path alias and use that instead of "manufacturer/#", however obviously this then pointed the user to the taxonomy term page, not the UC page. hook_link_alter() would allow us to redirect "taxonomy/term/#" to "manufacturer/#", but I still think we need to allow users to redefine how "manufacturer/#" itself is output.

We could do this internally as a setting, but for the most flexible option, I think we can register with pathauto to allow users to create an alias for our urls using the available tokens.

I still think using hook_link_alter() is a good idea, but AFAIK it's not a solution to the original problem (unless we also included the code I posted above, which would lookup the path alias -- but the user would still need to setup a pathauto recipe for manufacturer term links). Alternatively, I think implementing a uc_manufacturer_pathauto($op) function might give the option to customize our links.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Re: Manufacturer and Catalog links don't honor path
Assigned to:wazdog» Lyle

You can't do it with pathauto, but the path module in Drupal core lets you manually create aliases for any Drupal path. hook_link_alter() allows that to happen without any special coding on my part. I just put 'manufacturer/'. $tid in the 'href' field, and any alias that exists is used. Get the latest code from Bazaar to see what I've done.

Now that URL aliasing works on the catalog, I can actually implement all the pathauto features and simplify a settings page at the same time. Awesome.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Pathauto for catalog pages

...is here.

wazdog's picture
Offline
Joined: 12/11/2007
Juice: 18
Re: Re: Re: Re: Re: Manufacturer and Catalog links don't honor p
Assigned to:Lyle» wazdog

I don't think I was very clear... the point I was making is that we should implement the pathauto hooks so that users can rewrite uc links. It appears you've just done that, so I look forward to checking it out.

greggles's picture
Offline
Joined: 12/12/2007
Juice: 95
taxonomy links?
Assigned to:wazdog» greggles

If these are taxonomy links implemented via hook_term_path then perhaps this issue will help provide support: http://drupal.org/node/188606

wazdog's picture
Offline
Joined: 12/11/2007
Juice: 18
Re: Re: Re: Re: Re: Re: Manufacturer and Catalog links don't hon
Assigned to:greggles» wazdog

Yep, the new pathauto feature in uc_catalog is just what I was looking for. Thanks! I'd still like to see the same in uc_manufacturer, but it the catalog feature is great (except for the small bug I found and posted here

eugef@drupal.org's picture
Offline
Joined: 12/24/2007
Juice: 102
Re: Re: Re: Re: Re: Re: Re: Manufacturer and Catalog links don't
Assigned to:wazdog» eugef@drupal.org

Is this feature included in Ubercart beta?
Or i must use this patches?

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Re: Re: Re: Re: Re: Re: Manufacturer and Catalog links d
Assigned to:eugef@drupal.org» Lyle

It's in beta 2 at least. It was probably in the first beta though.

goodeit's picture
Offline
Joined: 05/28/2008
Juice: 322
Re: Re: Re: Re: Re: Re: Re: Re: Re: Manufacturer and Catalog lin
Assigned to:Lyle» goodeit

How hard would this be to adapt for uc_manufacturer. I've been looking hard for this kind of functionality, but utterly failed at incorporating pathauto into uc_manufacturer myself.

I think that there really only needs to be one "manufacturer" page, between browsing the taxonomy pages and viewing the pages generated by uc_manufacturer (which are now different). That would help keep things consistent and make aliases easier.

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
#13
Category:» support request
Assigned to:goodeit» Guest

Hey guys, didn't know where to post this, I'm hoping someone can help me out.

Using Drupal 5.x and UC 1.x

I am not sure when this started happening, but it seems some of my catalog menus have slowly been changing back to the /catalog/#/term format that wazdog mentioned above.

So right now I checked my pathauto and ran a bulk replacement using the following settings:

Node path settings > Product paths: [termpath-raw]/[title-raw]
Catalog path settings > catalog pages: [catpath-raw]

When I enabled the check boxes for Bulk replacement for both Node and Catalog, and clicked Save Configuration, it returned saying "0 aliases generated" and now I think _all_ of my catalogs have been changed to /catalog/#/term Yikes! So now many of my blocks are broken since the webpage addresses have changed.

Someone please help!
Thanks,
Mike

EDIT: I just went through my entire catalog 1-by-1 and just manually corrected the links by hand. Thanks