I know this has been asked before for D5 (sorry if I should have continued thread there but seemed appropriate to open separate issue for D6).

In short: is this still a "won't fix" or will Talk at one point integrate with Pathauto? I think this is really an important issue in order to present site users with consistent meta information.

TIA,
Gerben

Comments

cwgordon7’s picture

I explained this in the other issue as well. Adding separate path aliases for the /talk page will add significant overhead and nearly double the size of the already overburdened path alias table. This is the same reason for not aliasing the /edit page in pathauto. There's really no easily scalable way of doing this with the current path alias structure.

cwgordon7’s picture

Status: Active » Closed (won't fix)
Gerben Zaagsma’s picture

Ok, thanks for the explanation, I see the issue.

Gerben

john.kenney’s picture

sorry to revisit this issue again - feels like a bit of a hornet's nest, but the rationale is not as clear to me as it seems to be for others - and lack of SEO friendly paths is a showstopper for me because my sites are totally search driven. i'd otherwise very much like to use the module.

when you say there is "no easily scalable way of doing this...", are you saying that it is not possible to integrate with pathauto or are you saying it is inadvisable to integrate? i'm a technical nobody, but it sort of sounds like the reasoning is based on theoretical possibilities that problems might/will emerge with path alias structure in a big site that made heavy use of comments on every page.

but what if you have small sites - like 100 pgs - and comments aren't on every page? does this create the same type of problems you are referencing? i assume my path alias tables are tiny compared to how big they get on larger sites, so i'm struggling to see how i could overburden much of anything.

if a different answer might apply to smaller sites with fewer comments, how hard would it be to write the code to do it?

thanks for considering this.

cwgordon7’s picture

Status: Closed (won't fix) » Active

I suppose we could add this feature. It would need some sort of warning on it though, and wouldn't mass-add/delete path aliases upon changing the talk node types, that would have to be done manually. I'll consider this an active feature request, and if someone writes a patch for this, that would be amazing; otherwise, I may or may not get to it.

john.kenney’s picture

oh, awesome! that would be great.

i'm not quite sure what you mean by 'wouldn't mass-add/delete upon changing the talk node types'?

what would you guess is involved with writing a patch? in terms of hours, how to do it, ...

no promises, but i will look into getting a patch done.

cwgordon7’s picture

In the patch, you would want to:

a) Add a setting to integrate with pathauto.
b) If this setting is enabled, add a path alias when a node is inserted or updated.
c) Delete the extra path alias when the node is deleted.

The part that would be hard, and which I advised not doing, would be to mass add/delete path aliases when one changes the talk node types. For example, consider what should happen on a site with 10,000 pages, where the page node type is now set to use talk pages. Ideally, all these nodes would be updated, and their path aliases' would be extended to their talk pages, but that would be dangerous to do on some (most?) sites. A workaround solution would require the nodes to be re-saved before having any changes go into effect.

In terms of hours, if you know what you're doing, you can probably do it in less than 3 hours. If you're not quite sure, it could take around 8 hours to figure everything out. If you need any help in learning to write code or create a patch, I'd be happy to help. Alternatively, I might look into this feature request in more detail in a few weeks or so and write the patch myself. It would be wonderful if you could write the patch though, and would ensure that the code makes it quickly and efficiently into the module. :)

cwgordon7’s picture

To elaborate, you'll probably want to borrow some code from the path module, and simply modify it to work on talk pages if the node type is talk-enabled. Also, the option shouldn't be available unless the path module is enabled.

john.kenney’s picture

ok, excellent additional info. that's very helpful. thank you very much.

i see your point about the mass-add/delete now. doesn't apply to me, but i understand the issue there.

writing a patch is well beyond my skills - even your 8 hrs estimate is probably low by a factor of 10x. best to engage a professional. :)

what i had in mind was to ask a freelance consultant i work with to assist on this. if he can do in 3 hrs or so, that's affordable. 8 hrs not so much. if you are able to coordinate with him, that'd be great, too.

he's very skilled with drupal and i'm sure would generate code that's very clean and works well. obviously we'd test it on my little sites and you'd be able to review/refine. i'm thinking that tuning it for larger sites - the mass-add/delete thing - might be something we leave for you/others, but perhaps you guys can sort that as well.

not sure exactly when he'll be able to look into this. hopefully within the next week or so.

flevour’s picture

Assigned: Unassigned » flevour
Status: Active » Needs review
StatusFileSize
new4.07 KB

Hi there,
attached is a patch that addresses the issue as you suggested. There is also a draft of testing, but testing in Drupal is too slow to go for TDD and stay (little) under 2 hours for this implementation :)
Tested with (not so) good old point and clicking and looks fine, let me know!
Francesco

john.kenney’s picture

fantastic! that was quick.

i will give it a try and post results here.

Status: Needs review » Needs work

The last submitted patch, path-integration.patch, failed testing.

john.kenney’s picture

wasn't able to get it working.

patch command wouldn't apply patch, so i hand patched. hopefully did that correctly.

some of the new mechanisms are visible - e.g., new path alias checkbox on talk config page. but it wouldn't enable via checkbox and save. so i manually changed in talk.module to 'TRUE' to enable. still no joy.

flevour’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
StatusFileSize
new4.1 KB

Previous patch was rolled against DRUPAL--1-6 with
# cvs diff -u -N -F^f . | grep -v -e ^\?
Rerolling against DRUPAL--1 with
# cvs diff -up | grep -v -e '^\?'
As per CVS instructions on project page tab.

cwgordon7’s picture

Status: Needs work » Needs review

This looks very good. I'm going to let the test bot run this because it has some nice-looking tests. I noticed a few minor things, though:

+      '#title' => t('Generate an alias version of bla bla'),
+      '#default_value' => variable_get('talk_pathauto', FALSE),
+      '#description' => t('BLA BLA.'),

Mind removing the "bla bla"s? :)

cwgordon7’s picture

Also, it doesn't work to use variable_get('talk_pathauto') when the variable name is 'talk_pathauto_integration'.

Also, even though you added a setting, you never actually read the value anywhere, so if the path module is enabled, the talk page will be aliased regardless of the settings.

john.kenney’s picture

i am not able to get patch to apply. possible doing something wrong in patching process after recent change from windows to ubuntu. following procedure here - http://drupal.org/node/620014 - but this may not apply to ubuntu.

did not try to manually patch the latest version - but sounds like that wouldn't work due to items in #16.

cwgordon7’s picture

The patch applies fine for me. Are you sure you're (a) working off the development branch, (b) running the patch command from the module's folder? Patching procedure should be the same on ubuntu.

john.kenney’s picture

yes, on both counts.

after further investigation, i figured it out. problem relates to permissions within ubuntu /talk directory. i don't have adequate permissions - and don't know how to change it. need to fix that. has been a problem in other instances, as well.

so, i moved /talk folder over to windows machine where i know i have the right permissions. ran patch command. patch applied with no problems. then moved updated module back over to ubuntu. bit cumbersome, but did the job.

even after changing FALSE > TRUE, patch doesn't actually work - but i think that's what you are saying in #16. requires some tweaks.

flevour’s picture

StatusFileSize
new4.2 KB

As English isn't my first language, I'd love if you or John could suggest a title and a description for the patch.

I now actually use the talk_pathauto_integration variable.
In the hook_nodeapi I'm also checking for path module existance, to address the case the talk_pathauto_integration was enabled and the path module was disabled later on (very edge case, but anyway).

john.kenney’s picture

how about something like this:

for checkbox line:

Generate aliased paths for talk pages

for description underneath checkbox:

Use pathauto to generate talk page paths based on the existing node alias. If existing path alias is /page-title, talk pages will have path /page-path/talk. If not enabled, default talk module paths will be: /node/xx/talk. Use caution when enabling this feature on large sites as this can significantly increase load on path alias table. Requires pathauto module.

cwgordon7: does this sound about right?

john.kenney’s picture

also, cwgordon7, can we add option in module to control the alias used for talk pages? so, for instance, if i wanted my talk pages to be /page-title/comments instead of /page-title/talk.

same idea as you have for the existing options - like renaming the 'talk' tab to be 'comments' tab.

flevour: can you implement this, please? i guess this requires a variable that works like the others on the talk config page.

john.kenney’s picture

okay, tried out the patch, including inserting suggested text.

1. suggested description text has a typo. corrected (and shortened) text is below:

Use pathauto to generate talk page paths based on existing node aliases. If existing alias is /page-title, talk pages will be /page-title/talk. If not enabled, talk module paths will be: /node/xx/talk. Use caution when enabling on large sites as it may significantly increase load on path alias table. Requires pathauto.

Checkbox label same as above: Generate aliased paths for talk pages

2. the alias checkbox now seems to save properly. default box setting is unchecked. box remains checked after saving.

3. alias are not being generated. do i need to do something to generate them? tried clearing cache and running cron.

Anonymous’s picture

@#23:

Because of the way this is implemented, each path needs to be updated *after* the patch is installed.

The patch works fine for each page after I update it by hand.

Perhaps someone who understands this better than me could write a short script to update all existing paths?

And perhaps that could be made to run automatically when the module is installed/updated?

Anonymous’s picture

Tiny typo: "heavily" (used in code comment) has only one v in it.

Anonymous’s picture

Title: pathauto integration for D6 version » alternate path integration for D6 version

Um... actually... this has nothing to do with pathAUTO, does it? It applies equally to "alternative paths" set explicitly when an individual page is edited. (That works for me -- with the proviso that the path has to be updated for it to take effect.)

I suggest changing the checkbox description to something like:

Generate talk page paths based on the node's alias. If the existing alternative path is /page-title, the talk page path will be /page-path/talk. If not enabled, default talk module paths will be: /node/[nid]/talk. Use caution when enabling this feature on large sites as this can significantly increase load on path alias table. Compatible with, but does not require, the pathauto module.

flevour’s picture

StatusFileSize
new4.51 KB

#22: John, open one more issue to keep track of your "control talk' path alias" feature request.

#24: that's exactly something cwgordon is concerned about (see #5 of this issue, "wouldn't mass-add/delete path aliases upon changing the talk node types"). Anyway it would be cool to provide a checkbox for "Bulk update" very similar to pathauto option.

Attached is a patch that takes the suggestions from #21 (headline) and #26 (description).

Cwgordon, what is your opinion on the issue?

Anonymous’s picture

#22: I had the same idea without noticing this post, and opened a new issue, #751334: Option to use string different from "talk" in path.

Anonymous’s picture

Rather than adding the talk page on insert/update, could talk_nodeapi() check on 'load' to see if the talk page alias exists, and add it if it doesn't? Would there be an unacceptable performance hit from that?

greggles’s picture

This feels like a bad idea to me for reasons charlie outlined in #4.

Also, there is a module - http://drupal.org/project/subpath_alias - which will allow for a scenario:

* node/10 has the alias "blog/greg/this-is-a-blog-post"
* node/10/talk without a new alias automatically becomes "blog/greg/this-is-a-blog-post/talk"

So, that part of this issue is now handled quite well. We do need to consider how to change the alias from "talk" to something else like "comments" but I think custom_url_rewrite/hook_url_rewrite is the right way to do that rather than thousands of aliases.

Anonymous’s picture

#30: cool. This seems like the right thing (as far as I understand the issues). Thanks for the pointer to that module.

Do I understand correctly that this is an alternative approach from that suggested in #7, and implemented by flevour in #27? (Rather than a supplement to it.)

I will try implementing the #30 idea sometime in the next few days and let y'all know how it works out.

john.kenney’s picture

@a1tsal: did you have a chance to try the suggested sub-path alias module?

as i understand @greggles comment, this module (and required dependency module http://drupal.org/project/url_alter) is a complete replacement for patch flevour has written (#27) and this is his understanding as well. it isn't obvious to me how installing two additional modules to solve this problem which it seems we were very close to solving with ~40 extra lines in flevour's patch is a superior method, but apparently there are technical issues beyond my understanding and these modules solve those problems more comprehensively.

i am now not sure where/how the path gets changed from the default of '/talk' to an alternate, e.g., '/comments', but i believe we are saying that issue have been migrate off this thread to your thread here: http://drupal.org/node/751334. this is fine to move it - as long as there is effort to get it done.

greggles’s picture

The reason subpath_alias module is technically superior is one of slippery slopes. If we make an exception and create duplicates aliases for talk module then we should also do it for module Signup which creates about 5 sub tabs. So, if we have 6 sub aliases for every node that is a performance and maintenance nightmare.

john.kenney’s picture

oh, i think i may see what you are saying.

is this a fair restatement: instead of having talk module (and potentially every other module) implement their own individual subpath solutions, the subpath alias module solves the problem once for all modules that might require it.

and as well, that whereas scalability is stated as the problem at the beginning of the thread, the issue is perhaps more about consistency / consolidation of where/how this is done.

greggles’s picture

Yes, that is definitely a big part of it. The second part is this: having 5 aliases per node in the url_alias table will start to slow down performance of the site.

john.kenney’s picture

ok, very good. i think i see what you are saying. the subpath_alias module just works with the last bit of the path whereas what we were doing re-wrote the entire path, potentially multiple times if there are numerous subpages. i can see where that creates a lot of entries - maybe not for my sites which are small, but in the more general case. let's leave it there.

hopefully a1tsal and i will both get these modules working and we'll have part of the solution.

now, we just need to fix the /talk vs. /comments thing for it to be actually usable.

Anonymous’s picture

#32: No, sorry, I haven't had any time to work on this recently. It will probably be a couple of weeks before I get back to it, I'm afraid -- other responsibilities.

I have a dev server running a hacked-up version of Talk with various extensions, and I will definitely be migrating it to the live site, one way or another. I will provide patches with the work I've done when I do the migration -- but others may beat me to it.

Anonymous’s picture

OK, thanks to greggles' #30, we have a solution that works, requires no patch or coding, and also solves #751334: Option to use string different from "talk" in path.

This does not use Subpath Alias, which I couldn't get to work in this application. However, Subpath Alias is built on URL Alter (http://drupal.org/project/url_alter), and there is a simple way of using it to do the job. After installing and enabling URL Alter, go to Admin > Site configuration > URL Alter.

In the top box, put:

if (preg_match('|(.+)/talk$|', $path, $matches)) {
  $src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', '') ORDER BY language DESC",
			    $matches[1],
			    $path_language ? $path_language : $GLOBALS['language']->language));
  if ($src) {
    $result = $src . "/talk";
  }
}

In the bottom box, put:

if (preg_match('|node/(\d+)/talk|', $original_path, $matches)) {
  $dst = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = 'node/%s' AND language IN('%s', '') ORDER BY language DESC",
			    $matches[1],
			    $path_language ? $path_language : $GLOBALS['language']->language));
  if ($dst) {
    $path = $dst . "/talk";
  }
}

Do "Save configuration", and that's that. (A tiny change in the above addresses #751334: Option to use string different from "talk" in path; see that issue for details.)

I can write this recipe into README.txt and provide a patch file, once I've figured out how to do that.

Anonymous’s picture

Oh, yes, two loose ends, regarding caching.

I think you may need to clear the page cache to get this to work. I'm not sure. Please let me know, and I can put that in the documentation.

There is also a potential performance issue. The code in Subpath Alter goes to a lot of trouble to cache database requests. I am assuming that the URL Alter outgoing hook will be called only once per time a comment URL is displayed on a page; and since comment URLs are liable to appear only once per page, caching wouldn't help, and the performance hit from this approach is tolerable. I have not actually checked this. If for some reason the Drupal core repeatedly calls the outgoing hook on each URL, some rethinking would be needed.

john.kenney’s picture

thank you for this. but it isn't working for me.

well, it is partly working. the path is getting rewritten, but it's taking me to a 'page not found' result.

i've tried doing with both /talk and /comments variations. this produces the path: /page_path/talk (or /comments) as you'd expect, but clicking on the link takes you to the page not found.

btw, i did need to clear cache before the new paths became visible to me at all.

might there be some other step?

john.kenney’s picture

fiddled with it some more. not working.

i tried uninstalling everything, reinstalling, clearing cache at each stage. i specifically made sure the patched talk module was replaced with the original.

same result: paths are rewritten (they look beautiful!), but when clicked they take you to page not found.

i tried installing subpath_alias to see if that helped that caused all subpaths to break on my test site. e.g., /page_path/edit also goes to page not found. if it worked, looks like it would be nice.

disabling both modules brings me back to the beginning with paths working again absent the aliases.

Anonymous’s picture

Oh, dear, I am sorry you are having trouble with this. Actually I had exactly the same symptom at first: outgoing paths were being re-written (i.e. the URL linked on the page was /pagename/comments), but they were not recognized incoming (clicking on the URL got a 404 Not Found). I poked at it for a while, and the problem went away, but I'm not sure what I did that fixed it.

I did turn off caching completely for a while (both page cashing and CSS caching). I assumed that clearing the page cache would fix the problem if this was relevant, but possibly you actually need to turn caching off for a while, and that somehow deals with the 404 issue. If that is not the answer, then I'm stumped.

Greggles, do you have any ideas, based on your experience with Subpath Alter and/or URL Alter?

This is really an issue for URL Alter, not for Talk. We should file an issue over there, if you can't get it working soon. They will need a small, reproducible test case. The thing would be a to do a clean Drupal install in a dev environment, install just Talk and URL Alter, set the URL Alter PHP code, and see if it works. If not, that is something the URL Alter maintainer should be able to easily reproduce and fix. If it does work, then we know that something else about your configuration (and formerly mine) is responsible for the problem.

Good luck... the URL Alter approach does work for me (http://approachingaro.org/the-tibetan-book-of-the-undead/comments), but I did have to spazz around for a while to sort out the 404 issue.

Anonymous’s picture

Oh, whoa, whoa, whoa! Maybe this is the problem:

In the URL Alter admin page, there should not be the <?php and ?> tags. I wrongly included them in my instructions #38. I have edited that to remove them.

john.kenney’s picture

@#43
yes, i did remove the php tags. wouldn't actually accept them. makes you remove them, so that's not the problem.

not able to read you other post thoroughly at the moment, but wanted to clear up that one point. will get to it tomorrow.

thank you!

john.kenney’s picture

i tried this again today. still not able to make it work.

i am on a localhost test site and there is no caching enabled at all, so that's not a factor.

i cleared cache via pma. machine has also been shut down and restarted in the meantime, so that should clear most any other weird thing.

i tried out just url_alter and subpath alias on another site (no talk module) - the simplest one i've got in terms of fewer modules - but got same result. outbound path is rewritten, but the destination path is not seen to exist.

since subpath alias module does not work in any situation, i suspect the issue is not specific to interaction of talk and url_alter modules, but rather something to do with the new destination url not being written properly at all for anything.

any ideas what would cause that? i will post on url_alter to ask there because, as has been pointed out, this appears not to be about problem with talk module.

http://drupal.org/node/774596

Anonymous’s picture

OK, it seems that URL Alter has some fundamental problem. I'm kind of surprised that lots of people seem to be using it without complaint. The issue must affect only certain configurations. But if you have tested it on a site without Talk installed, then it's clearly not a Talk issue.

I am afraid that the maintainer of URL Alter is over-committed, and you may not receive a timely response to your bug report.

All URL Alter does is provide an interface to the two custom_url_rewrite functions (http://api.drupal.org/api/search/6/custom_url_rewrite). They are part of the Drupal core.

It should be possible to use the custom_url_rewrite functions instead of URL Alter. Basically, the code I provided can be the body of those functions. You might need to make tiny changes to fit the API.

You would want to disable and uninstall URL Alter before trying this -- it will interfere with the core custom_url_rewrite.

If it doesn't work, let me know and I will try and help; you should also be able to get help on the forums, because custom_url_rewrite is part of core and should be well-supported, where URL Alter might not be.

Good luck... I am really sorry for the time you have had to spend on this.

john.kenney’s picture

thank you very much for your efforts to help.

i was also surprised that so many people seem to be using url_alter without incident. i assume its working for all of them. why it wouldn't work for me, too, i have no idea.

it sounds like you have a good understanding of the code involved. unfortunately, the solution you describe is well above my pay grade. no skills as a code writer.

i will put this back over to flevour and ask if he can make take a look and fix the problem.

thanks again.

Anonymous’s picture

Great. Flevour, if you make this work using custom_url_rewrite, could you please post here the exact code you used?

If John reports success with that, I will write documentation incorporating it, and we can mark this issue fixed.

The hooks URL Alter provides are in the 7.x core, so the 7.x version of Talk should use them to do this (rather than requiring users to mess with custom_url_rewrite per documentation).

Anonymous’s picture

Status: Needs review » Needs work

Um, I guess since URL Alter appears to be flaky, the solution I gave here does not work reliably; so this is "needs work", not "needs review".

john.kenney’s picture

that sounds right.

i put up an issue about this in the url_alter queue. no response so far.

it will be another week or more before flevour is able to take a look at this.

Anonymous’s picture

I have just found that in Drupal 7, the Sub-pathauto module (http://drupal.org/project/subpathauto) handles this automagically, out of the box, with no configuration required (beyond installing and enabling it).

Yayz.

jarodms’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)