Customizing SMF > SMF Coding Discussion

Display topic starter name (SMF 1.1.x)

(1/2) > >>

Derp:
HI there,

This may be a noob question, but how do I display the topic starter name inside display.template.php?

I'm doing a costumization where in the top of every topic i want to show something like "Thread Author: X", but I'm kinda frozen here...

Thanks for your time!

tinoest:

--- Code: ---    // Show the topic information - icon, subject, etc.
    echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-bottom: 0;">
        <tr class="catbg3">
                <td valign="middle" width="2%" style="padding-left: 6px;">
                        <img src="', $settings['images_url'], '/topic/', $context['class'], '.gif" align="bottom" alt="" />
                </td>
                <td width="13%"> ', $txt[29], '</td>
                <td valign="middle" width="85%" style="padding-left: 6px;" id="top_subject">
                        ', $txt[118], ': ', $context['subject'], ' &nbsp;(', $txt[641], ' ', $context['num_views'], ' ', $txt[642], ')
                </td>
        </tr>';

--- End code ---

Find the above and replace what you want to in there.

Derp:
Hi tinoest and thanx for your answer.

Actually that isn't what I need. I know where to edit but I don't know the code to show the topic author.

In your example we can see $context['subject'] to show the subject and $context['num_views'] to show number of views... but how do i show the name of the user who started the thread?

In messageindex.template.php I figured that is $topic['first_post']['member']['link'], but that doesn't seems to work on display.template.php... I'm missing something, maybe in source files?

Thanks anyway :)

cicka:
Can you try this for the conditional?


--- Code: ---if($context['topic_starter_id'] == $message['member']['id'])
--- End code ---

tinoest:

--- Quote from: tinoest on August 15, 2012, 01:25:49 PM ---
--- Code: ---    // Show the topic information - icon, subject, etc.
    echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-bottom: 0;">
        <tr class="catbg3">
                <td valign="middle" width="2%" style="padding-left: 6px;">
                        <img src="', $settings['images_url'], '/topic/', $context['class'], '.gif" align="bottom" alt="" />
                </td>
                <td width="13%"> ', $txt[29], '</td>
                <td valign="middle" width="85%" style="padding-left: 6px;" id="top_subject">
                        ', $txt[118], ': ', $context['subject'], ' &nbsp;(', $txt[641], ' ', $context['num_views'], ' ', $txt[642], ')
                </td>
        </tr>';

--- End code ---

Find the above and replace what you want to in there.

--- End quote ---

I think it is in the measage var , you will need to add a conditional as explained above.

Navigation

[0] Message Index

[#] Next page

Go to full version