Skip to main content
Topic: Need infos about function template_build_poster_div (Read 4896 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Need infos about function template_build_poster_div

Maybe I missed something important but why is function template_build_poster_div() (related file is Display.template.php) build using  a concatenated string $poster_div = .'blablabla'...
Code: [Select]
function template_build_poster_div($message, $ignoring)
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

$poster_div = '';

// Show information about the poster of this message.
$poster_div .= '
<ul class="dropmenu">
<li>';

I think it's far better readable to just echo the output than to write the whole html into a concatenated string and do a return at the end?

Code: [Select]
function template_build_poster_div($message, $ignoring)
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

// Show information about the poster of this message.
echo '
<ul class="dropmenu">
<li>';
Thorsten "TE" Eurich
------------------------

Re: Need infos about function template_build_poster_div

Reply #1

Could be that a javascript could use the string for its container - not uncommon in displaying a popup for example. But here it seems the return isn't cached.

If custom themes needs this, they prob. rewrite the subtemplate anyway. I vote for making it output it directly.

Re: Need infos about function template_build_poster_div

Reply #2

Same here... templates should output, not return. Actually, that should be a rule, if it starts with template_ it should have no return value. Just because it is in a template file, doesn't mean it needs to start with template_ though. If it is a template helper, maybe start it with helper_

Re: Need infos about function template_build_poster_div

Reply #3

Quote from: Bloc – Could be that a javascript could use the string for its container
Yay, that's it  :) Thank you. It's aparantly the box, if you hover over the username. Will add it to the function's doc.
Thorsten "TE" Eurich
------------------------

Re: Need infos about function template_build_poster_div

Reply #4

Quote from: TE –
Quote from: Bloc – Could be that a javascript could use the string for its container
Yay, that's it  :) Thank you. It's aparantly the box, if you hover over the username. Will add it to the function's doc.
Still though, it should output and not return

Re: Need infos about function template_build_poster_div

Reply #5

No, it can't output then...it has to wait until echoed within the javascript code, which often comes afterwards. But, in this instance it isn't afaics, unless that variable is global'ed somewhere else?