universal aliasing for taxonomies (was: separate aliasing for image galleries)

vito_swat - November 1, 2007 - 21:46
Project:Pathauto
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

This is somehow related to separate aliasing for forums and forum containers.

Image_gallery module (part of image module) similar to forums use taxonomy in not common way. It introduces paths like image/tid/[tid] for terms. I created patch which is similar to forum one to handle this issue.

AttachmentSize
pathauto_19.patch5.47 KB

#1

vito_swat - November 1, 2007 - 23:22

Forgot one slash to properly delete alias

AttachmentSize
pathauto_20.patch 5.47 KB

#2

greggles - November 2, 2007 - 13:13
Status:needs review» needs work

thanks very much for providing this, I think it will be a great feature.

One question - can you review this issue: http://drupal.org/node/188762

From a site of mine that uses image galleries it doesn't look like the image module provides any specific feed integration. So, we'll want to remove
+ $settings['supportsfeeds'] = '0/feed';

Also, if you can create your patch with "cvs diff -up" that makes it much easier to read.

#3

vito_swat - November 11, 2007 - 04:41
Title:separate aliasing for image galleries» universal aliasing for taxonomies (was: separate aliasing for image galleries)
Version:5.x-2.0-beta5» 5.x-2.0
Status:needs work» needs review

During my studies on Drupal API I found very useful function taxonomy_term_path(). With it's help I was able to simplify solution for non-standard categories like forums and image galleries. All vocabularies are now handled by taxonomy_pathauto hook whenever they are standard or not.

To properly handle bulkupdate a hack was needed. I'm setting additional alias for taxonomy/term/[tid] to know that this term is already aliased. For example:
We have forum which source url is forum/14. We set pathauto to set this url to forums/this-is-test-forum. After my patch there will be 2 rows in url_alias table:
forum/14 -> forums/this-is-test-forum which is desired behavior
and
taxonomy/term/14 -> /forum/14 which is needed for pathauro to know that this term is aliased.

A nice side-effect is that even if we type in url www.example.com/taxonomy/term/14 we will get forum view instead of taxonomy view. If we have Global redirect module than Drupal redirects us straight on www.example.com/forums/this-is-test-forum.

I tested this patch with forum, image galleries and superb taxonomy redirect module and it's working fine.

Sorry for not creating my patch with -up parameter but my eclipse is unable to do it (or I don't know how to set up it properly).

AttachmentSize
pathauto.patch 7.27 KB

#4

eMPee584 - November 13, 2007 - 13:02

Mhh I was just having the same issue (image_gallery's wired URLs) and was about to create some freak-patch for pathauto when I saw this.. do I need to apply the previous patch aswell.. or is this about to hit CVS anyways? thx & cheers..

#5

greggles - November 13, 2007 - 13:05

@zuriel please review the patch in #3. test it out, look at the code and the approach. look for ways to improve it, etc.

@vito_swat - I haven't tested this yet, but do thank you for your investigation and novel approach to this idea. Hopefully it will solve this problem in a general way.

#6

vito_swat - November 23, 2007 - 12:49
Status:needs review» needs work

There's no rule to have [tid] in uncommon taxonomy source path (but most have) so feed path for such a term will be broken.

I have to rethink this code once again and I'll provide new patch during weekend. I'd like to implement this with much cleaner code and without 'dummy_taxonomy' thing.

#7

vito_swat - November 25, 2007 - 13:57
Status:needs work» needs review

This is new patch against current dev. I think it's much cleaner now. Again tested with modules: forums, image galleries and taxonomy redirect.

It also fixes a bug with creating alternate feed aliases even if there was 'Create a new alias. Delete the old alias.' option selected. To sovle this (and to reduce code) I introduced a new function _pathauto_existing_alias_data() which consist of part of the pathauto_create_alias().

AttachmentSize
pathauto.patch 10.02 KB

#8

greggles - November 25, 2007 - 14:19

It also fixes a bug with creating alternate feed aliases even if there was 'Create a new alias. Delete the old alias.' option selected. To sovle this (and to reduce code) I introduced a new function _pathauto_existing_alias_data() which consist of part of the pathauto_create_alias().

Can you clarify specifically what that bug is/was? I don't understand it from your brief description.

Also, please see RFC: should feed aliases get updated following normal "update action" settings? and discussion on groups.d.o about the topic of updating feed aliases when the underlying alias is updated.

#9

vito_swat - November 26, 2007 - 11:08

Problem is exactly the same as described in RFC. I'll reroll patch tonight and I'll omit that part of the code until discussion ends.

#10

vito_swat - November 29, 2007 - 22:22
Version:5.x-2.0» 5.x-2.x-dev

This took me little more than expected (I've so many work to do) but I finally rerolled the patch vs current dev and without changes in creating new feed aliases when 'Create a new alias. Delete the old alias.' option is selected.

Please review.

AttachmentSize
pathauto.patch 9.65 KB

#11

tj2653 - December 1, 2007 - 17:54

subscribing

#12

tj2653 - December 3, 2007 - 04:27

Hi,

I tried this patch on a clean copy of Pathauto 5.x-2.x-dev. The image paths are working great now, but my forum paths aren't working anymore. I deleted all my aliases, and bulk generated everything. It looks like the paths are generated in the URL alias list:

forums/category/discussion taxonomy/term/1
forums/category/discussion/general taxonomy/term/2
forums/category/discussion/other taxonomy/term/3

But when I browse to the forums, here are the page locations:

Discussion http://mydomain.com/forum/1
-General http://mydomain.com/forum/2
-Other http://mydomain.com/forum/3

My setup in PathAuto is: [vocab-raw]/category/[catpath-raw], and this was working correctly before the patch. Any ideas?

EDIT: Actually, it's also not working for a few other sections, like blog and faq.

Thanks

#13

herb - December 3, 2007 - 22:12

I just applied the pathauto_23.patch to the current dev version, and it seems to have fixed the problem I was having getting the image galleries to be correctly aliased.

I deleted all the category path aliases and then let the patched version run with the default settings for image galleries. Everything worked fine. I deleted them again, and changed the pattern to photo-albums/[catpath-raw].

It worked again, but gave a warning for each photo-album created.. user warning: Duplicate entry '2324' for key 1 query: INSERT INTO url_alias_extra (pid, dst, entity_type, entity_id, created_by) VALUES .........

However, the correct aliases were generated. Thanks

#14

vito_swat - December 4, 2007 - 09:37

@tj2653
Could you check if you have following aliases for forum (I assume you have /forum/1..3 as you noted):

taxonomy/term/1 -> forum/1
forum/1 -> forums/category/discussion

taxonomy/term/2-> forum/2
forum/2 ->forums/category/discussion/general

etc.

@herb
This warnings are not related with the patch I provided. They show also on clean dev release. Check: http://drupal.org/node/196465#comment-643634

#15

tj2653 - December 4, 2007 - 18:23

Hi vito_swat. The only forum-related aliases are the ones I posted above:

forums/category/discussion -> taxonomy/term/1
forums/category/discussion/general -> taxonomy/term/2
forums/category/discussion/music -> taxonomy/term/3

They used to point to forum/1, forum/2, etc. before the patch (I deleted all aliases, and regenerated all aliases with the patch).

#16

vito_swat - December 5, 2007 - 00:56

Well it seems that forum module don't implement hook_term_path, so it still needs special handling. I reverted forum specific functions I deleted in previous patch (but I don't like this solution) and made issue #197864 in Drupal forum module to make it properly in core.

My forum module was heavily modified so in my test environment it was working... Please test it carefully with forum and image galleries (add, edit, delete terms and nodes for both modules).

AttachmentSize
pathauto.patch 5.36 KB

#17

tj2653 - December 5, 2007 - 01:30

Thanks - before I test this out, is this expected to also fix my similar problems with blog and faq taxonomy aliases?

#18

vito_swat - December 5, 2007 - 02:13

This patch does not touch any blog aliases so I think your problem is not connected with this patch. If you have any other special taxonomies that don't work please provide detailed steps to reproduce the problem.

#19

tj2653 - December 5, 2007 - 03:30

I should clarify that they were blog and faq taxonomies...for instance they used to look like:

blog/category/fashion -> taxonomy/term/50
blog/category/food -> taxonomy/term/51
faq/category/general -> taxonomy/term/28
faq/category/posting -> taxonomy/term/29

I don't have what they turned out to be after my first patch because I've rolled back the DB, but the URLs were not the same (not blog/category/fashion, etc). I just tried the new patch, and either I patched incorrectly, or there's a problem. It says 50 aliases were created, but the list only shows 2, which are malformed:

blog/category/food -> taxonomy/term/
taxonomy/term/ -> taxonomy/term/51

#20

vito_swat - December 5, 2007 - 03:53

I still don't know what modules do you use!

You mention FAQ. The only FAQ i found was the http://drupal.org/project/faq. If this is module you use than it doesn't have hook_term_path implemented so it will not work with this solution unless you post feature request to implement it.

The blog taxonomy also seems to be non-standard but I don't know what module is generating it. Can you provide result of the query SELECT vid, name, module FROM vocabulary on your database. It will help me to check if the patch will work for your modules.

my results are:
1 Forums forum
2 vocab taxonomy
3 Image Galleries image_gallery
4 FAQ taxonomy

And it works for all the cases except FAQ as I mention above.

#21

tj2653 - December 5, 2007 - 04:47

Yes, that's the FAQ module. Here are the results:

1 Forums forum
2 Category taxonomy (faq)
3 Category taxonomy (Organic Groups - og)
4 Category taxonomy (a CCK content type)
5 Image Galleries image_gallery
6 Category taxonomy (another CCK content type)
7 Category taxonomy (Blog)

All of the URL aliases except for Image Galleries were working with Pathauto until I implemented the patch. Is it possible to just patch for image_gallery and leave everything else the way it worked before?

#22

vito_swat - December 5, 2007 - 13:05

I'll ask you again what modules do you use? I cannot reproduce your issues. Especially I cannot create any special vocabulary for blogs, and faqs are working the same way as before the patch (without the alias).

Please provide complete step-by-step instruction how can I reproduce your issues starting from point: install and enable module XXX version ZZZ. I have clean drupal 5.3 install with enabled blog, forum, pathauto(dev) faq(2.5) and image(dev) modules and after applying the patch I can't make pathauto to behave in the way you mention.

If you don’t help me I couldn’t make the patch better. Making it only for image galleries is bad practice because there are other modules which uses taxonomy the same way as image galleries (ie. taxonomy redirect).

EDIT:
I played more with my test enviroment and I guess your problem is with incorrectly patched module. For your convenience as an attachment I provide files that changed.

AttachmentSize
pathauto_24.zip 15.69 KB

#23

herb - December 5, 2007 - 18:08

I use tried using the current pathauto_24.zip to replace my previously 23 patched 5.x-2.x-dev.

I deleted all url aliases using vocabularies and terms and it seemed to delete all aliases, except the image gallery aliases.

I regenerated all vocab url aliases, and it worked fine. However, I think the last patch let me delete the image gallery aliases.

CORRECTION: - I just went back to patch 23 and it exhibited the same erroneous behavior - it doesn't seem to delete the image gallery aliases when you delete all url aliases using vocabularies and terms.

#24

tj2653 - December 5, 2007 - 16:42

Hi,

I realized that when I applied the second patch, I did it on 5.x-2.0 and not 5.x-2.x-dev. That explains the strange behavior with the malformed URL aliases in #19. Patch #16 seems to be working for me now, with all my modules. The modules I listed in #21 were the only ones that I have installed that are related. Thanks for your help.

#25

greggles - December 16, 2007 - 20:22

vito_swat - thanks for your persistence with this issue.

I'm uploading a re-rolled version since HEAD has changed somewhat. I didn't test this with forum aliases (i don't use forum) or forum feeds. I'll do that shortly.

AttachmentSize
pathauto_24_2.patch 5.48 KB

#26

greggles - December 16, 2007 - 20:56
Status:needs review» patch (to be ported)

I made one slight code change to remove the space between the function name and the ( in _pathauto_existing_alias_data( but otherwise this worked as specified and fixed some relatively annoying bugs.

Otherwise this is applied to DRUPAL-5--2 and just needs to be ported (probably it will apply cleanly, but I haven't tested yet).

Thanks so much, vito_swat.

#27

greggles - December 16, 2007 - 21:32

So...another question is how people can clean up their sites.

Should people delete aliases associated with image/tid/ and then edit/submit all of the terms for image galleries?

Also, after applying this I noticed that links from taxonomy/term/58 point to image/tid/58 and then image/tid/58 points to the actual alias.

Before the patch, aliases would get -0 added onto the end, now the (less important) taxonomy/term alias points to something that is not very friendly. I'm sure we'll get some people who don't see it as an improvement. The way this patch creates aliases makes the global redirect module pretty important.

#28

Taiwan - December 23, 2007 - 18:59

I have a question regarding the best way to go about creating paths for taxonomies within my site.

The end result is I want to see a url liek this:

www.sitename.com/taxonomy/*identifier*/title where identifier is not a token, but taxonomy and title are.

I have already created 4 separate taxonomies, and some of them I don't want/need showing up as their own url. do you have any advice for this?

#29

greggles - December 31, 2007 - 20:19
Status:patch (to be ported)» fixed

fixed in HEAD as well.

@Taiwan - your question is totally unrelated to this thread. Please open a new issue or ask your question in a different place instead of just adding it to some random issue.

#30

Anonymous - January 14, 2008 - 20:22
Status:fixed» closed

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

#31

NancyDru - March 25, 2008 - 18:39
Status:closed» needs review

There was a piece missing: http://drupal.org/node/238213. Please apply the patch and test. Thanks.

#32

greggles - March 25, 2008 - 19:48

Here's the patch from that issue for completeness...

AttachmentSize
pathauto_path.patch 448 bytes

#33

NancyDru - March 25, 2008 - 23:19

Missing a one line piece: patch attached.

AttachmentSize
pathauto_path.patch 448 bytes

#34

greggles - April 30, 2008 - 14:24
Status:needs review» fixed

Applied to both HEAD and 5.x-2. Thanks, NancyDru.

#35

NancyDru - April 30, 2008 - 16:03

Thank you.

#36

Anonymous (not verified) - May 14, 2008 - 16:16
Status:fixed» closed

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

#37

mariagwyn - September 5, 2008 - 20:30
Status:closed» active

Does anybody know if this was applied in the drupal 6.x version?

I ask b/c I have that version installed, and when I override my Image taxonomy, to get it to work, I have to do two steps:

1. Override using tax_redirect from tax/term/# to image/tid/!tid.
2. Manually create aliases from image/tid/# to image-galleries/friendly-name/friendly-name.

If I understand this thread (and I may not), this should do this automatically. Or no?

thanks,
maria

#38

greggles - September 5, 2008 - 21:14
Version:5.x-2.x-dev» 6.x-1.x-dev
Status:active» postponed (maintainer needs more info)

@mariagwyn - please update to the latest 6.x-1.x-dev which had a small fix related to this and should fix your problems.

#39

mariagwyn - September 8, 2008 - 14:48

I updated to 6.x-2.x-dev, an all seems well. Thanks!
M

#40

mariagwyn - September 8, 2008 - 14:48
Status:postponed (maintainer needs more info)» closed
 
 

Drupal is a registered trademark of Dries Buytaert.