Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The hook_language_switch_links_alter()
should provide information on whether a link is from the language switcher block or the node links, which it doesn't from all I can tell now. I've been searching and asking around for how to do this, but to no avail, so I'm considering this a flaw in the API. If not, it's a feature suggestion for D8.
See also #1005144: Doesn't differentiate between node and language switcher blocks.
Comment | File | Size | Author |
---|---|---|---|
#15 | return-renderable-array-1009360-15.patch | 1.04 KB | Devin Carlson |
#13 | return-renderable-array-1009360-13.patch | 790 bytes | Devin Carlson |
#8 | return-renderable-array-1009360-8.patch | 1.05 KB | Devin Carlson |
Comments
Comment #1
plachWell, language_negotiation_get_switch_links can be called in any context so it shouldn't make assumptions on who's calling it.
Perhaps we should change locale_block_view to return a renderable array, so it can be
hook_block_alter
'ed.Comment #2
klonos...coming from #1005144: Doesn't differentiate between node and language switcher blocks
Comment #3
klonos...any progress on this? Any of Francesco's suggestions thought of? I guess for the second one to happen a separate issue needs to be filed in core. Right?
Comment #4
plachI'd say that
locale_block_view
should return a renderable array anyway to allow a format-agnostic theming. Let's fix this and see if it's enough to make Language Icons work.Comment #5
Freso CreditAttribution: Freso commentedWe already have the data used in
locale_block_view()
available viahook_language_switch_links_alter()
. I doubt changinglocale_block_view()
will help with the context awareness needed to have Language icons figure out how to treat branch. I'll try and make a patch that does as you describe shortly.ps. Sorry about any uncomprehensionality. It's very late and I'm heading to bed now, just wanted this answered first. :)
Comment #6
plach@Freso:
What I mean is that if we return a renderable array instead of a flat string its content may be altered through
hook_block_alter
. Node links are already alterable throughhook_node_view_alter
, so we should be able to tell the context in both cases.Comment #7
plachChanges are performed in the development version first, backported then.
Comment #8
Devin Carlson CreditAttribution: Devin Carlson commentedA patch to make
locale_block_view()
return a renderable array.Comment #9
klonosThe patch in #8 can be (manually) applied to D7 too, but I wouldn't know what to do with it :/
@Freso: Hey Frederik, any chance you can take a look at it and see if you can work something out with #1005144: Doesn't differentiate between node and language switcher blocks??
Comment #10
plachShouldn't this be using
'links__locale_block'
instead?19 days to next Drupal core point release.
Comment #11
Freso CreditAttribution: Freso commentedI'll try and give this a look/review this week, if time allows. *crosses fingers*
Comment #12
batigol CreditAttribution: batigol commentedcool
Comment #13
Devin Carlson CreditAttribution: Devin Carlson commentedReroll of #8 using
links__locale_block
(which is correct but might not provide any benefit anyway after reading #48 from #588148: theme_links() is not really themeable).The patch is now smaller as the changes are now made to language.module and no longer include any attached CSS or JS.
Comment #14
steinmb CreditAttribution: steinmb commentedGetting old. If this still is valid, It prob. need a re-roll.
Comment #15
Devin Carlson CreditAttribution: Devin Carlson commentedThe language switcher block was converted to a render array around the time that blocks were converted to plugins.
I believe that this is a D7-only issue now.
Comment #16
mitokens CreditAttribution: mitokens as a volunteer commented