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.
Could you please move the phptemplate_links() function into it's own include file, then have an admin option to switch on/off the inclusion of this function? It would be preferable to having to hack the module file to remove it (because I am implementing my own version of the function in another module).
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#9 | fix_phptemplate_links_name_collision.patch | 1.25 KB | justin2pin |
#7 | fix_phptemplate_links_name_collision.patch | 2.22 KB | justin2pin |
#5 | make_phptemplate_links_optional.patch | 6.98 KB | justin2pin |
Comments
Comment #1
flaviovs CreditAttribution: flaviovs commentedSure this is a real issue. I'm bumping this bug to critical because if you enable the module and your theme already have a
phptemplate_links()
function, then you will severily break your site (PHP spits out "already defined function" error and you can't disable the module anymore).(If you're experiencing this problem, the only solution is to edit your theme's
template.php
file and comment out thephptemplate_links()
function, access the module listing, disable the Menu Trails module, and only then uncomment your originalphptemplate_links()
function.)Comment #2
mortendk CreditAttribution: mortendk commentedand now were at it by having a phptemplate_links() theme call in the module it will screw up any theme inheritance that a themer wants to have in his setup. it goes in and overwrites the parenttheme_links() :(
Comment #3
sunCan someone check whether we still need phptemplate_links() at all? I've heard rumors that the stock theme functions would already apply the "active-trail" + "active" classes now.
Comment #4
eojthebraveI don't think this is still needed. theme_links now applies an active class to the li element of active menu items in the same way that this function does, which it previously did not.
However, the phptemplate_links() function contains this line of code
$link['attributes']['class'] .= ' active';
that the new theme_links does not. This sets an active class on the a element as well as the li element. Is this necessary? Any examples of something where a.active would work and li.active a would not?If we do still need it though this could be done in a preprocess function.
Comment #5
justin2pin CreditAttribution: justin2pin commentedGlad to see I'm not alone with this issue.
I created a patch that moves phptemplate_links() into a separate include file and adds a settings option to choose not to include it. The file is included by default.
Hope it's useful.
Comment #6
sunThis won't fly.
Instead, we want to massage the theme registry, and only alter theme_links into menutrails_links in case the theme system didn't detect another theme override function.
Comment #7
justin2pin CreditAttribution: justin2pin commentedOk here's another try -- this time using hook_theme_registry_alter() to register "menutrails_links" if default "theme_links" function is being used.
Comment #8
sunerm?
This should be an inline comment.
Instead of completely overriding the entire info, we just want to replace the 'function' in the array.
Lastly, this should not happen under any circumstances.
I'm on crack. Are you, too?
Comment #9
justin2pin CreditAttribution: justin2pin commentedIssues addressed as noted - let me know if this works.
Comment #10
sunThis can also be fixed before committing, so just FYI: function names in comments should always be suffixed with parenthesis, i.e. function_name(), to make clear that it's talking about a function.
I'm on crack. Are you, too?
Comment #11
beeradb CreditAttribution: beeradb commentedI've used this on a handful of client sites now without problems. Assuming the commenting issues can be fixed when committing, it would be great to get it into a release.
Comment #12
sunThanks for reporting, reviewing, and testing! Committed to 6.x.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.