This patch adds two features:
- option to keep aliases only for published nodes
- enable/disable pathauto per node

Currently it can't recognize which aliases where created by pathauto. So in case where no alias should be set for node, it deletes ALL aliases for given node.

I didn't want to create whole new table for enable/disable part so i justa added field to node table. But i know some may object this. I'm not really sure which way is better. With additional table it could also store which alias is which there, but that not only would double space needed for aliases, but also slow down module a bit.

CommentFileSizeAuthor
pathauto_3.patch5.59 KBahwayakchih

Comments

jsbthree’s picture

I wanted to add something to this for clarification.

"The patch works well for modules that auto create nodes. The best example
of auto created nodes in this case is Aggregator2 which creates full nodes
from RSS feeds. Some feeds will by design have a short shelf life -- e.g.
news -- and the publisher may not want the content indexed at all. In these
cases creating full natural language paths is both a waste of resources and
possibly counterproductive."

ahwayakchih’s picture

Assigned: ahwayakchih » Unassigned

just changing assigned, so maybe someone will review it :)

mikeryan’s picture

Assigned: Unassigned » mikeryan
Status: Needs review » Needs work

Please do not assign issues to yourself, except for modules which are your own responsibility.

Adding a field to the node table isn't acceptable for a contributed module. This implementation in general is rather a hack, I won't apply it as is.

I can see having a checkbox to override automatic creation of aliases in the node form, but not much point to saving the setting with the node. I'll look at adding such a check box.

It's a good point that aliases aren't really useful for unpublished nodes. Pathauto is already suffering from option bloat, however - instead, I'll look at generating aliases only for published nodes as the default behavior.

ahwayakchih’s picture

Please do not assign issues to yourself, except for modules which are your own responsibility.

Yes, sorry for that.

Adding a field to the node table isn't acceptable for a contributed module. This implementation in general is rather a hack, I won't apply it as is.

First i also thought it's not acceptable, but i also didn't want to create new table just for one option. Then i thought that if it's so much unacceptable then why there's "fields" op in hook_nodeapi? Also because pathauto works for all possible nodes, having field in node table is quite logical.
So the only thing against it (and what makes it "hack") is that pathauto is contributed module, and node table is controlled by core module.
Another thing is that i thought pathauto module will go into core someday?

I can see having a checkbox to override automatic creation of aliases in the node form, but not much point to saving the setting with the node. I'll look at adding such a check box.

Well... i described my reasons above :) Thanks for looking into it.

I guess it could be temporary value, not stored anywhere in database. Just checked by pathauto and node save time. But then it would have to be "check this to NOT generate aliases". Then it would also work when node is saved by other modules from some automatic job (like from aggregator2 :). Heh, why i didn't think of that before? :)
I can make new patch if You want.

It's a good point that aliases aren't really useful for unpublished nodes. Pathauto is already suffering from option bloat, however - instead, I'll look at generating aliases only for published nodes as the default behavior.

Yes, it might be good idea. Just remember to remove them after node is unpublished/deleted.

ahwayakchih’s picture

Errata:

Just checked by pathauto and node save time.

I ment: "Pathauto would look if it's checked at node save time" :).

greggles’s picture

So, this issue evolved into a couple of things:

1. don't create aliases for unpublished nodes. (which is a separate issue: http://drupal.org/node/61505)
2. Don't create aliases if a checkbox is present on the node $edit

If someone wants to make a patch for item 2 then I could see committing it. One question I have about that is whether it needs a new permission for "Control Pathauto Creation" or if we should just show it for people who are allowed to create paths manually? Or show it to everyone?

My preference is a new permission, but I could be swayed.

greggles’s picture

Status: Needs work » Closed (duplicate)

Item #2 from my comment #6 was implemented in http://drupal.org/node/170673 so I'm marking this a duplicate of that.

The ability to determine which nodes should get aliases is also controlled by which nodes have patterns. You can delete the default if you don't want all node types to get an alias.