Skip to main content
Topic: Just curious about php syntax. (Read 17141 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Just curious about php syntax.

When I was looking through templates yesterday, I noticed this:



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>';

    // Show a link to the member's profile.
    $poster_div .= '
                                <a href="' . $scripturl . '?action=profile;u=' . $message['member']['id'] . '">
                                    <span class="name">' . $message['member']['name'] . '</span>
                                </a>';

Obviously the $poster_div .=' is just substituting for the old echo' and is doing the same job, but echo' is still used in other places. What's the rationale regarding the new syntax? It's more verbose, and I can see it being possibly more confusing, but I assume there is a reason it was chosen.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Just curious about php syntax.

Reply #1

I did that (and this was asked and answered before  O:-) ) ... That code is used in to places, so rather than duplicate 99% of the same code in two places I chose put in in a separate function and just call it to build the info and then echo it back.

Re: Just curious about php syntax.

Reply #2

Ah. So is this to deal with both posts and PM's with less code overall?
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P

Re: Just curious about php syntax.

Reply #3

It was a while ago that I did that, but I seem to recall it was for when the "no avatar" option which was changed to a compact view as a test/request ... not sure that is still even in the theme  O:-)

Anyway at one point that code was called either by the sidebar avatar view or by the dont show avatars (= no sidebar crud) view

Re: Just curious about php syntax.

Reply #4

Yeah I like the no sidebar crud option as an option. I was going to tweak it so that the name went with the keyinfo h5 etc, and the post went full width under all that. I can see that being quite a popular option, especially for notebooks.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P