when you create a project it should be creating a path alias: "project/<shortname>", but it's not.

after poking around a bit, I discovered that it was creating the alias, but the path module was unsetting it again imediately because the path modules form element was either empty or non existant.

I think the trick might be to set the path modules form element during validation, but I haven't had any success doing that yet. I'm not up to speed on the new forms api.

Comments

moggy’s picture

Status: Active » Needs review
StatusFileSize
new493 bytes

It seems we can't change the node during validation anymore.

This patch create a new function: project_project_submit, a hook that's called on submit which sets the path

dww’s picture

Assigned: Unassigned » dww

i thought the current behavior might have been considered a feature, so drupal.org admins could manually specify aliases once projects were considered "worthy" or something. ;) however, i just got the following from killes in IRC:

killes: dww: I think we'd prefer the aliases to be created automatically.

so, i'll test this patch and hopefully apply it in the near future. there are some minor typos in the comment, but don't bother rolling a new patch, it's easy enough for me to fix that.

thanks!
-derek

dww’s picture

Status: Needs review » Needs work

i can't get the patch working on a local test site. :( this doesn't seem to solve the problem. i'll try more testing when i've had some sleep, but it appears this patch still needs work. can anyone else verify that this works or not? thanks!

-derek

dww’s picture

Status: Needs work » Needs review

ok, i found the problem with your previous patch:

function project_project_submit($node) {

to modify $node, you needed this:

function project_project_submit(&$node) {

so that we use a reference to $node, not a copy of it.

however, your patch had another, more fundamental problem. by relying on path_nodeapi() to do the work, this also prevented aliases from getting created when users that don't have the 'create url aliases' permissions create projects. of course, these are exactly the kinds of users that we *want* the aliases created automatically for. ;) that's one of the primary points of having this feature, especially on drupal.org.

here's a new patch that just calls path_set_alias() directly to accomplish this task. note, we do this in project_nodeapi(), not project_project_submit() so that we do it when we've already got the nid of our new project (this way, it works when creating new projects, as well as when editing existing projects).

furthermore, i'm using project_form_alter() to remove the "URL alias" fieldset from the project edit page when creating a new project, since this feature is always going to overwrite whatever you put in there. seems silly to present a field to the user that they can't really use. when editing an existing project, this fieldset is altered to be a 'markup' field to print out the existing alias (again, since you can't edit it, we shouldn't present it as a textfield).

i've tested heavily on a local site, both as a regular user and one who can create aliases, for new projects and editing existing ones. i think this is RTBC... anyone?

thanks,
-derek

dww’s picture

StatusFileSize
new1.87 KB

tee hee, the patch... ;)

dww’s picture

Status: Needs review » Fixed

in IRC, killes said this was RTBC. committed to 4.7 and HEAD. i confirmed this bug doesn't exist in 4.6, so there's nothing to backport.

dww’s picture

StatusFileSize
new1.17 KB

alas. there was a critical bug in the previous patch. we were creating aliases for issue nodes, too, since both issues and projects were sharing the same hook_nodeapi(). for the interested reader, here's the patch i applied that fixed it.

dww’s picture

see also http://drupal.org/node/69349 to fix this project_nodeapi() confusion.

Anonymous’s picture

Status: Fixed » Closed (fixed)
dww’s picture

Version: » x.y.z
Status: Closed (fixed) » Closed (duplicate)

duplicate with http://drupal.org/node/33239, which is the older issue. i just marked that one as fixed (had never noticed it until now when i was searching for something else)...