Closed (duplicate)
Project:
Pathauto
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
30 Jul 2008 at 16:26 UTC
Updated:
26 Apr 2012 at 16:20 UTC
"Automatic alias" checkbox should be configurable to default to unchecked (or checked).
Comments
Comment #1
gregglesIf this happens it will be in code only (i.e. not have a user interface to control the variable) and will be in 6.x-2.x (where all new features go).
Comment #2
Freso commentedShould be easy enough to implement. If we want to do this, what should the variable be called?
pathauto_perform_alias_default?Comment #3
gregglesAlso, this is really a desire to have update actions work properly and/or for the checkbox to respect the update actions which is fixed (among other things) in http://drupal.org/node/242456 so I think this is duplicate.
Comment #4
markj commentedActually, it would be useful to have an option under the General settings at admin/build/path/pathauto to not even show this checkbox in the node edit form's URL path settings' form fieldset, and for the help text to say something like "Enter an optional custom URL for this node". In other words, Path Alias would provide the option for people to create their own URL but not force automatic creation of the URL. Would you be willing to accept a patch that offers this combination of changes?
Comment #5
gregglesI'm not entirely sure that I understand that idea, but
1) Anything that involves adding a new option without removing some other options can't get in. The admin page is too overwhelming as it is
2) If I do understand what you're saying...it won't work during node edits.
Comment #6
markj commentedI've achieved what I'm after by using form_alter() in a site-specific module. In case anyone else is interested I'll document it here:
1) Make the custom module load later than Pathauto by giving it a weight of 2 in the {system} table (see http://drupal.org/node/110238 -- this can be done in the module's install file), since Pathauto has a weight of 1. We need to do this because we are applying form_alter() to a form that has already had form_alter() applied to it by another module (in other words, Pathauto is altering the core node edit form, and we are altering the alteration applied by Pathauto).
2) In our form_alter() function, add the following code:
3) Create a little Javascript file called pathauto_markslaptop.js (or whatever you call it in the drupal_add_js() function in your form_alter() function):
The overall effect is to make "Automatic alias" checkbox disappear from the node edit form (I mean totally disappear, there's no more option to auto generate) and to make it's value unchecked, so the user can add an optional path.
Comment #7
charmer commentedIs there any chance to port this feature to 5.x branch?
I'd appreciate if I could tell Pathauto whether it should start with 'Automatic Alias' ticked (both for new nodes and edit forms) per node type, but if it's too difficult, very simple option just to set up the default state of the checkbox would be nice and it would help me just the same.
Thank in advance.
Comment #8
priya_86 commentedAbout automatic aliases..
Comment #9
tahiche commentedRelated to markj´s solution...
I know it´s wrong to modify module´s files instead of overwriting functions and such, but then again, I keep seeing patches to alter modules files, right?.
My scenario:
1)On a generalo basis, I don´t want the editor to control the alias. But I don´t want to permanently exclude the posibility.
2) Paths are generated according to taxonomy tags...
Therefore if taxonomy is changed for a node, I want a new path generated. In that case pathauto interprets the paths are different and the checkbox (use automatic) is unchecked, which is an unwanted behaviour. So basically I want the checkbox checked unless you REALLY want to change it...
Simplest solution ever:
pathauto.js - line 5 (at the begining)
if ($("#edit-pathauto-perform-alias").length) $('#edit-pathauto-perform-alias').attr('checked', true);
Which basically checks it by default.
Comment #10
jusfeel commentedmy automatic alias box just gone for one content type from some reason...any idea where I can look into?
Comment #11
dave reidComment #12
ccshannon commentedWow, after an hour of head-banging (and no, not in the good way) @tahiche at #9 posts something that solves the problem that seems to have been plaguing pathauto for many versions now and is still not fixed in current version (1.5)
I don't create my nodes via Drupal UI. My nodes are imported from a php script and created using Drupal API calls (drupal_write_record NOT node_save). So, I thought the reason that the Automatic URL Alias checkbox wasn't getting checked was because of my imports, but then I remembered, "Hey, I've been doing these imports for two years and this wasn't a problem before .. hmmm" Ever since Pathauto 1.2, the checkbox has not been checked properly in defaults, and, get this, using form_alter does NOTHING. You cannot control the checkbox being on or off using form_alter. I'm not sure if that's Pathauto or a Drupal bug (foind lots of tickets of people not able to control checkbox defaults using form_alter).
Anyway, I'm commenting in this (closed) ticket because numerous other tickets about this issue have been closed without the problem actually being fixed.
Really, there should be a module setting that lets you default the checkbox to on or off, even better would be by content type, context, etc.
The only correction I would make to #9 code is to format it properly and NOT put it on line 5, rather start it at line 4 :
Comment #13
Eaglecanada commentedthis is a better method:
http://browse-tutorials.com/snippet/drupal-snippet-automatic-alias-check...
using #12, you have to give user administer url aliases & create url aliases permission
Comment #14
ccshannon commentedThe link is bad. There is a colon on the end that shouldn't be there.
Yes, that also works, but none of these solutions is really all that great, because they require hacking directly into the module. The module should offer the option to have the checkbox on or off by default.
Also, I would contend that you should have administer url aliases & create url aliases permission enabled to be able to have the alias checkbox in the first place, but to each his own.
Comment #15
Encarte commented@ccshannon: I also think «The module should offer the option to have the checkbox on or off by default.», but this was marked as a duplicate of #242456: Allow unique "Update Action" settings per item type (node, taxonomy,etc) or item (eg. page, story, vocabulary, etc). I think greggles marked it as a duplicate because he's concerned about the user-friendliness of the admin page and would rather have this feature on the node type page (and I think that makes sense).
Comment #16
ccshannon commented@Encarte: Thanks, I did not catch the duplicate issue! That sounds like a good way to go .. content type setting. :)