Needs work
Project:
Special menu items
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
31 Aug 2011 at 22:03 UTC
Updated:
11 Jun 2024 at 12:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedfor now I added a quick and dirty hook which is absolutely not solid because I have no idea how to check if a certain part of an alias belongs to a special menu item link.
Comment #2
gagarine commentedSpecial menu item are not link so they should note have aliases and should not passe trow transliterate
If I didn't understand please reopen.
Comment #3
Anonymous (not verified) commentedHere is the usecase:
setup pathauto to generate node alias like:
[menu-trail-parents-path-raw]/[title-raw]
You will end up with non transliterated url-parts for the special menu items.
Again, I am not sure if this is a pathauto issue or a special menu items issue.
Comment #4
melissavdh commentedI have used the following:
Comment #5
noah commentedNot sure if I've misunderstood the problem, but none of the solutions above fixed the issue for me (in D7). I have a resolution that works (I think), so here it is in case it's useful to anyone.
The pattern I'm using in pathauto is:
[node:menu-link:parent:url:path]/[node:menu-link:title]When a page is created that is a child of a special menu item, the generated URL looks like, e.g.:
<nolink>/about-usThe following function iterates through all possible parents, looks at the matching chunk of the alias, and transliterates it if it's equal to "
<nolink>":Note that this doesn't work for bulk updates, only when paths are generated automatically when creating or editing a node.
Comment #6
vrajak@gmail.com commented@noah,
Not sure how to implement this? Do I need to make a custom module? Or a module & have this in my template.php ? Some direction would be great.
Comment #7
noah commentedIt goes in a custom module.
Comment #8
aaronbaumanIMO this is a bug.
Special menu items should prevent this from happening - should not require a separate module.
Comment #9
seanbIt would be nice to be able to configure this somewhere. I think there are 2 options to handle this:
- Remove the part from the pathauto alias
- Replace the part with the display title
It would be nice to add this to the module. I will try to create a patch for both options.
Comment #10
seanbComment #11
seanbAdded some extra code to always remove separator menu items from the alias (just in case, these probably wont have child menu items anyway).
Comment #12
Adamation commentedHi SeanB I've applied this patch and I can see the new options:
However, when saving a node, the automatic URL alias still contains the title of the menu item.
For example my menu is as follows
- About Us {nolink}
-- Link 1
--- Link 1.1
--- Link 1.2
-- Link 2
When I assign a node to the menu I'd expect the PathAuto and your patch to make the URL become
www.mysite.com/link-1/link-11
However I'm still getting
www.mysite.com/about-us/link-1/link-11
Problem is About Us isn't a page, so we don't want it in the URL.
Thanks
Adam
Comment #13
gagarine commentedComment #14
spadxiii commentedI just applied patch #11 to 7.x-2.0 and it works great. Not that existing aliases aren't updated (automatically), but that's outside this patch's scope.
Also note that I have this alias pattern set up: [node:menu-link:parent:url:path]/[node:title]
When using [node:menu-link:parents:join-path]/[node:title], the no-link menu items are joined in the url with their menu titles.
I'm setting this back to needs review so that someone else can have another look. From what I can see, the patch works fine.
Comment #15
euskarez commentedI have the same problem.
I need to exclude from url menu item that is nolink but I need also to have in the url all the parents of a node until the root of my site.
[node:menu-link:parent:url:path]/[node:title] work with tha patch but use only the direct parent of the node.
[node:menu-link:parents:join-path]/[node:title] creates url with all parents but not work with the patch.
someone have any solution?
thanks!
Comment #16
gagarine commentedI don't understand why we need two option. We can only have on checkbox "Use the special menu item title in pathauto" and by default removing it...
Comment #17
gagarine commentedComment #18
spadxiii commentedI just ran into an issue with this patch: after saving a new node, the user is redirected to the homepage.
I traced it back to node_access returning a FALSE when setting up the form-redirect. This is because during the node_save, a node_access call is made before the node is fully saved. This then stores a FALSE in the drupal_static of node_access.
The cause of this early node_access call is this line:
$menu = menu_link_get_preferred($context['source']);Attached is a patch where I delayed the call when it is actually needed. Other than this, it's the same patch as #11.
I'm leaving this on 'needs work' because I agree with @gagarine that there should only be a single option for replacing with the title and remove by default.
ps. I also fixed a query-mistake and added { } around the table name.
Comment #19
seanbI agree that we really only need 1 checkbox. Since the default will then be removing the special menu items, do we need any update hooks or anything to make sure we don't break anything?
I'm not sure if the default behaviour should be removing special menu items, or if we should replace with the title by default.
Any ideas? When we make a choice I can update the patch accordingly...
Comment #20
seanbSorry, I see gagarine proposes to remove by default. I will update the patch!
Comment #21
gagarine commentedPlease work on the -dev version. When this one go in I will release a new stable version.
Comment #22
seanbNew patch is attached, showing only a checkbox to choose if you want te replace special menu items in pathauto aliasses. The special menu items are removed by default.
Comment #23
gmaxwelled commentedThe patch doesn't appear to work for me, I'm afraid. Have tried saving the configuration form with the box checked and without, and saving the nodes multiple times and creating a new node, but it always adds in the special menu item in the URL..
Comment #24
spadxiii commented@gmaxwelled: did you clear the cache after applying the patch? The patch adds a new hook-implementation which would probably not be picked up without a cache clear.
ps. I haven't reviewed the patch myself. Hiding my patch-file because the last one should be better :)
Comment #25
aitala commentedI have applied Path #22 to -dev and it also does not work for me. Neither did Patch # 18.
I am using the token
[node:menu-link:parents:join-path]/[node:title]I have cleared all the caches and such.
Eric
Comment #26
timfletcher commentedI ran into this recently, the issue for me was in Pathauto. I ended up using this as a workaround: https://www.drupal.org/project/special_menu_items/issues/1485784#comment...
Update PathAuto to v2.0 and use the page path token:
[node:menu-link:parents:join-path]/[node:title]instead of[node:menu-link:parent:url:path]/[node:title]However, this can introduce new issues in some situations; Parent pages that have a custom-defined URL i.e. not relying on Pathauto, will show up in the URL path as a transliterated path, e.g.
My great page (great)
L My child page (child)
When visiting 'My child page', the URL should read
mysite.com/great/child, but instead readsmysite.com/my-great-page/childComment #27
gagarine commentedComment #29
Uzdrupaller commented#11 patch was broken after 7.x-2.x-dev release 23 march. Adding patch that works with new version.