MyBB Community Forums

Full Version: Where can I find variables that are mentioned in templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone

I'm trying to customise a template and to do that I need to edit one of the variables (or use an altered copy of it). But... I don't know where to find where the variables are defined. Is there a specific place where the variables are stored, or what are the steps to discover where a variable is defined?

More specifically, I want to edit the "memberlist" template, which contains this code:

<tr>
<td class="tcat" width="1%"><span class="smalltext"><strong>{$lang->avatar}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->username}</strong></span></td>
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->joined}</strong></span></td>
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->lastvisit}</strong></span></td>
<td class="tcat" width="10%" align="center"><span class="smalltext"><strong>{$lang->posts}</strong></span></td>
{$referral_header}
</tr>

...and the thing I want to change is that which is indicated here as "{$lang->username}" (specifically, I want to add each members' biography underneath his name, in the member list).

I suspect I have to either edit that variable or create a copy of it and edit the copy, and then mention the copy's name in this template. But where would I find the place where that variable is defined?

Thanks
Samuel
(10-17-2013, 08:28 PM)ugcheleuce Wrote: [ -> ]Hello everyone

I'm trying to customise a template and to do that I need to edit one of the variables (or use an altered copy of it). But... I don't know where to find where the variables are defined. Is there a specific place where the variables are stored, or what are the steps to discover where a variable is defined?

More specifically, I want to edit the "memberlist" template, which contains this code:

<tr>
<td class="tcat" width="1%"><span class="smalltext"><strong>{$lang->avatar}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>{$lang->username}</strong></span></td>
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->joined}</strong></span></td>
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>{$lang->lastvisit}</strong></span></td>
<td class="tcat" width="10%" align="center"><span class="smalltext"><strong>{$lang->posts}</strong></span></td>
{$referral_header}
</tr>

...and the thing I want to change is that which is indicated here as "{$lang->username}" (specifically, I want to add each members' biography underneath his name, in the member list).

I suspect I have to either edit that variable or create a copy of it and edit the copy, and then mention the copy's name in this template. But where would I find the place where that variable is defined?

Thanks
Samuel

With what you want to do now you need to edit a language file .... from memory {$lang->username} is in the global language file ... edit the field to suit your needs .... however you can only use html code in these fields
Do you want to add a Biography Profile Field? If so, use Custom Profile Fields option.
(10-18-2013, 02:33 AM)Jimmy M. Wrote: [ -> ]Do you want to add a Biography Profile Field? If so, use Custom Profile Fields option.

Thanks, I have already done that, but I want the biography details from that custom profile field to be displayed in the members list. The reason is that I want all members to be able to see some information about other members in the list, without having to visit each profile page.

Anyway, I cheated a bit and didn't add any columns -- I simply changed the column headings (to plain text, since I don't understand the codes) in Admin CP > Templates and Themes > Templates > Memberlist Templates > memberlist...

<tr>
<td class="tcat" width="1%"><span class="smalltext"><strong>{$lang->avatar}</strong></span></td>
<td class="tcat"><span class="smalltext"><strong>Username, profession and languages</strong></span></td>
<td class="tcat" width="25%" align="center"><span class="smalltext"><strong>Training</strong></span></td>
<td class="tcat" width="15%" align="center"><span class="smalltext"><strong>Experience</strong></span></td>
<td class="tcat" width="10%" align="center"><span class="smalltext"><strong>{$lang->posts}</strong></span></td>
{$referral_header}
</tr>

...and then I added some new custom profile fields...

[Image: 24uz21i.png]

...and then I added those in Admin CP > Templates and Themes > Templates > Memberlist Templates > memberlist_user, as follows:

<tr>
	<td class="{$alt_bg}" align="center">{$user['avatar']}</td>
	<td class="{$alt_bg}">{$user['profilelink']}<br />
<span class="smalltext"> <!-- 
	{$user['usertitle']}<br />
	{$usergroup['groupimage']}
	{$user['userstars']} -->{$user['fid6']}
</span></td>

	<td class="{$alt_bg}" align="center"><span class="smalltext">{$user['fid8']}</span></td>
	<td class="{$alt_bg}" align="center">{$user['fid7']}</td>
	<td class="{$alt_bg}" align="center">{$user['postnum']}</td>

<!-- <td class="{$alt_bg}" align="center">{$user['regdate']}</td>
	<td class="{$alt_bg}" align="center">{$user['lastvisit']}</td>
	<td class="{$alt_bg}" align="center">{$user['postnum']}</td> -->
	{$referral_bit}
</tr>

Say, what is the correct way to comment out code in the templates? I find that the HTML method doesn't always work (some times variables inside commented-out blocks are still active). I guess I'm going to have to learn some PHP. (-:

Thanks again for all your assistance.
Samuel
^ just a note: above comment tags should work but comment tags for the php variables might not work