I'm quite sure its a duplicate but wasn't able to figure out which one.
This patch is missing the UI for setting the variable for which there are several possibilities.
- node-type configuration: /admin/structure/types/manage/article
- pathauto UI: /admin/config/search/path/
- path auto extra-field configuration
- ...
You often want to use pathauto for some content; disabled for every other content.
The rationale of this patch is that you may also want to use pathauto in some case while keeping it mostly disabled for newly created nodes.
With this patch (+ the missing UI bits), you can disable the automatic generation on a per-bundle basis.
On a side note: $pattern = pathauto_pattern_load_by_entity($entity_type, $bundle, $langcode);
can be rewritten if(pathauto_pattern_load_by_entity($entity_type, $bundle, $langcode)) return;
as $pattern
is not used.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1422908-entities-no-path-still-get-checkbox.patch | 851 bytes | Dave Reid |
pathauto-default-checkbox-value.patch | 1.83 KB | drzraf | |
Comments
Comment #1
Dave ReidAh, I see what's going on. When there is no available pattern for a specific entity type and bundle, we mistakenly return out of pathauto_field_attach_form() rather than setting $form['path']['pathauto'] to a FALSE value. Currently it will not add anything to the form which then on submit means that !isset($node->path['pathauto']) which means do apply an automatic alias, which is not desired in this case.
Comment #2
Dave ReidComment #3
Dave ReidPatch attached for review, this also needs a unit test to confirm its behavior and ensure we don't have a regression in the future.
Comment #4
Dave ReidHrm, I'm not sure about this after some review - if there's no pattern, then there's no reason to show an Automatic alias checkbox since checking it would do nothing on node save since there would be no pattern to alias from. The current behavior of 7.x-1.x is correct. This isn't in fact a bug, my mistake.
The originally proposed feature will not be accepted into Pathauto since having a pattern for a content type assumes new content should have that pattern by default. As such, I'm marking this issue closed as a won't fix.
If you want to alter the Pathauto checkbox for new nodes, then you should use something like this in a custom module:
Comment #5
drzraf CreditAttribution: drzraf commentedI'm fine with using this hook, which does the trick (thanks).
( Anyway other people may find an UI for this to be valid feature request )
Comment #6
drzraf CreditAttribution: drzraf commentedSorry to bumb, but I'm not aware of any workaround for taxonomy terms edit forms.
Comment #7
Dave ReidYeah you'd have to manually form_alter the taxonomy form and $form['path']['pathauto']['#default_value'].
Comment #8
jeremiahtre.in CreditAttribution: jeremiahtre.in commented@Dave Reid
I'm attempting to leave the checkbox checked. In my custom module I can't get #4 to work for new or existing nodes (tried both in logic). I even installed
pathauto_persist
, just in case.I am using your recommended version, however. Is this dev-only? Alas, here's what I've altered to fit my needs:
Issue
No matter what, I cannot get the "Generate automatic URL alias" button to be checked. Even on node creation, with a pattern defined.
Motivation
For permissions and semantic reasons (for our many authors) we want the node form to always have this checked. For example: when they change the menu item, we want to make sure that the alias (patterned to menu parents + join) matches that updated menu position.
Thanks for your time, and we truly appreciate this module.
jtreinau
Comment #9
jeremiahtre.in CreditAttribution: jeremiahtre.in commentedWell, turns out Panopoly implements a form_alter to change the value.
Among other Panopoly-specific overrides, here is what code worked for me:
Could probably be more specific as to what form I am selecting. Nevertheless, it works.
jtreinau