Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The admin page provided by this module is not linked from any existing page. This page is not reachable from any navigation. So admin users who don't know the exact page path won't know the existence of the setting page of this module.
Proposed resolution
Add a menu item in hook_menu()
to make the existing page "File system" /admin/config/media/file-system
a tab.
Remaining tasks
Make a patch
Review the patch
User interface changes
A tab menu is added in the admin page "File sytem".
API changes
None.
Data model changes
None.
I'm not sure if this is a bug. If it's not a bug, please feel free to change the Category. Thanks.
Comment | File | Size | Author |
---|---|---|---|
#21 | filefield_paths-n2895026-21.patch | 2.3 KB | DamienMcKenna |
#11 | filefield_paths-admin_page_visibility-2895026-11.patch | 2.56 KB | oadaeh |
| |||
#11 | interdiff-2895026-2-11.txt | 2.54 KB | oadaeh |
#3 | filefield_paths-admin_page_visibility-2895026-3.patch | 1.79 KB | oadaeh |
| |||
#3 | interdiff-2895026-2-3.txt | 1.71 KB | oadaeh |
Comments
Comment #2
hgoto CreditAttribution: hgoto as a volunteer commentedComment #3
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commentedI found that adding the MENU_DEFAULT_LOCAL_TASK menu item was unnecessary and produced a superfluous Defaults tab.
Also, the description for the field on the admin page needs some correcting.
Attached is a patch that addresses both of those.
Comment #4
hgoto CreditAttribution: hgoto as a volunteer commented@oadaeh thank you for joining this thread.
I tested your patch. It cleanly applies but doesn't add any link, I see. Don't we need to have at least one
MENU_DEFAULT_LOCAL_TASK
when we want to useMENU_LOCAL_TASK
?If you don't mind, I'd like you to share the capture of the page you realised. Thank you.
Comment #5
hgoto CreditAttribution: hgoto as a volunteer commentedComment #6
loopduplicateThe way to render tabs is documented here:
https://api.drupal.org/api/drupal/modules!system!system.api.php/function...
The MENU_DEFAULT_LOCAL_TASK entry is needed. Here's an updated patch and interdiffs, with the hook_menu item indentation formatted for Drupal code standards. It also includes the description fix and end of file line break fix that was included in #3. I've also included a description, adapted from the module description, "Configure improved Token based file sorting and renaming functionality."
Comment #7
loopduplicateOK, this conflicts with Transliteration. I'll update the patch.
Comment #8
loopduplicateHere's a patch which checks to see if other modules have included a default. I used hook_menu_alter(), which was already implemented in an include file. I moved the hook to the main module file and broke out the functionality into two separate functions. I wish there was a way to check for default tasks.
The other option I thought of was to not create a tab, but instead create another main menu entry at admin/config/media/, "admin/config/media/filefield-paths". This would ensure that we don't conflict with other contrib modules and would simplify the code quite a bit. Anyway, that's just something to chew on.
Comment #9
loopduplicateMinor grammar fix.
Comment #10
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commentedOkay, I see how Transliteration was causing me to incorrectly evaluate the situation.
However, the patch that @loopduplicate provided did not work correctly for me. I still had both a Defaults tab and a Settings tab, both of which were pointing to the same page. The reason is because
$file_system_menu_items = $items['admin/config/media/file-system'];
is specifying a single path, and it is not the path the Transliterate module uses, so the path the Transliterate module uses is not be found. I understand the path the Transliterate module uses cannot be specified explicitly, as that might include some other module doing the same thing.It took me a while, but I was finally able to update the patch so that was fixed for me.
I also made a few other changes:
1. I moved the location in the file of
filefield_paths_menu_alter_image()
, because I didn't feel like the function I added to address the multiple tabs had a "proper" place, so I ordered the relevant functions based on execution order, beginning withfilefield_paths_menu_alter()
.2.
Technically speaking,
MENU_CALLBACK
evaluates to empty:Since the code really only cares about
MENU_DEFAULT_LOCAL_TASK
, this could be reverted, if desired, but the comment should be modified.3.
I think "Settings" is a more appropriate label for the tab.
4. I made a few other changes to comply with Drupal Coding Standards, but only to the code related to this patch.
Comment #11
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commented@loopduplicate and I had a conversation out of the issue queue, and we believe that rather than jumping through all the hoops we are trying to get through, it would be easier to just place the menu item one level up the chain on the Configuration page.
I've attached a patch that does that, but also keeps the description fix on the admin page itself.
Comment #13
loopduplicateThe patch failed testing but I think it was a problem with the testbot. So, I re-queued the test.
Comment #14
loopduplicateThe patch in #11 looks good to me. What do you think, @hgoto? RTBC?
Comment #15
loopduplicateMENU_NORMAL_ITEM is the default if type is not specified so we can omit this line. See https://api.drupal.org/api/drupal/modules!system!system.api.php/function... . "If the "type" element is omitted, MENU_NORMAL_ITEM is assumed."
Comment #16
oadaeh CreditAttribution: oadaeh at Hook 42 for Zicasso, Inc. commentedHere's an updated patch without the menu type specification.
Comment #18
loopduplicateIt makes no sense that the pathauto test would fail after this commit, but that's what the testbot says. Oye... re-requeueing :)
Comment #19
loopduplicateOK, tests are passing. Marking as RTBC now.
Comment #20
hgoto CreditAttribution: hgoto as a volunteer commented@oadaeh @loopduplicate thanks. I agree completely with you :)
+1 to RTBC.
Comment #21
DamienMcKennaA quick reroll.