Ok, default ternary (ZOMFG) is this...
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? $context['current_action'] : (!empty($context['current_board']) ?
'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . $context['current_board'] : '', '">';
I want to do this (ie: with action and area) but it doesn't echo the area to the body tag.
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? $context['current_action'] : (!empty($context['current_board']) ?
'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . $context['current_board'] : '', !empty($context['current_area']) ? ' area_' . $context['current_area'] : '', '">';
Why not? What gives? Who stole my area, and can I get it back?
Do a var_dump() to confirm the existence of your variable. It should throw an undefined index.
You need to either define it yourself in template_init() or read the request param manually.
https://github.com/SimpleMachines/SMF/search?q=current_area
Sounds gnarly.
Welcome to the world of code, where things work in unexpected ways, things you think might solve the problem don't, require more code and time than was planned for, and poor documentation all around.
Lol. I was well aware of that already.
However, I'll have to post that cartoon about dogs again...
You can post that cartoon about talking to dogs again if you like. It was amusing.
But if you want to be able to change the code to fit your desired outcomes, it's up to you to learn how the code works so that you can. Your cartoon about talking to dogs is funny because the human uses human language in an attempt to get the dog to do what the human wants. But if the dog decides it wants to argue about politics at human dinner parties, the dog can't very well complain that people keep talking with words instead of barking.
Fair point, but on a support forum the dog might expect a few tips on basic English.
live627 gave you some good pointers already. ;)
Looks like it's $context['admin_area'] for admin and moderation area, $context['menu_item_selected'] for PM area and profile area.
Any other user of generic menu may not export it at all.
I might try replacing the ternary with the modified array I used in 2.0.x for this. Clearer and easier to read anyway, and seems easier to modify.
Ternaries rapidly get ridiculous once you get past a simple if : else.
Downside is it might not actually work because there were a LOT of changes in 2.1...
Learn by breaking things ;)
Well that's a total bummer. The old array works flawlessly, is extremely easy to modify, and makes for cleaner HTML. Whoopee. :D
ETA: And goes in function template_html_above() not function template_init()
The former already has $context as global, so it just works.
Although obviously I could add $context as a global to template_init() if there was any benefit in having the array in that function.
Quote from: Antechinus on May 17, 2022, 02:09:11 PMAlthough obviously I could add $context as a global to template_init() if there was any benefit in having the array in that function.
it's optics/organization