Customizing SMF > SMF Coding Discussion

Display problem

(1/2) > >>

The Wizard:
Hello:

I want the cute dog image to show up under karma in the user post except the cute dog image shows up before the users posts. How can I fix this?

Below is my Displaytemplate.php code to display the cute dog image.

Thanks

wiz



--- Code: ---// Show SMFShop Item Cute Dog Image Version 0.1
if (!empty($settings['show_gender']) && $message['member']['dog'] != '')
    echo'
                                <li class="im_icons">', $message['member']['dog'], '</li>';
--- End code ---

The Craw:
So you want it to display as "Posts: {dog} 500"? If that's the case, you don't want to put your image in a separate <li> tag, but rather inside the post count's <li>.

The Craw:
This should display the image next to the post count, instead of above or below it.


--- Code: ---
// Show how many posts they have made.
if (!isset($context['disabled_fields']['posts']))
echo '
<li class="postcount">', $txt['member_postcount'], ': ', !empty($message['member']['dog']) ? $message['member']['dog'] . ' ' : '', $message['member']['posts'], '</li>';

--- End code ---

Obviously, you'll want to replace the existing post count code with that.

The Wizard:
I sorry I should have posted all my work to this point to give you all I better understanding of the problem
but I was up very late last night.

So here is what I have done so far:

just before the
--- Code: ---?>
--- End code ---
in Load.php I have the following function:


--- Code: ---//BEGIN SMFShop Item Cute Dog Image Version 0.1
function onUser ($id_member) {

    global $db_prefix, $smcFunc, $user_info, $boardurl;

      $request = $smcFunc['db_query']('', '
              SELECT shop_Dog
              FROM {db_prefix}members
              WHERE id_member = {int:id_member}',
              LIMIT 1', // it's good practice to limit your query length
array(
        'id_member' => $id_member,
)
);

$temp = $smcFunc['db_fetch_assoc']($request);
if($temp['shop_Dog'] !== "") {
                echo "Cute Dog: <img src='{$boardurl}/Sources/shop/dog_images/{$temp['shop_Dog']}'><br>";
                }

}

//END SMFShop Item Cute Dog Image Version 0.1
--- End code ---

Also in Load.php in the $memberContext[$user] = array after this code:


--- Code: ---'gender' => array(
'name' => $gendertxt,
'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''
),
--- End code ---

I added the following code:


--- Code: ---'dog' => onUser($profile['id_member']),
--- End code ---

Then in the Display.template.php after this code:


--- Code: ---// Show the member's gender icon?
if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
echo '
<li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
           
--- End code ---
         
I added the following code:


--- Code: ---// Show SMFShop Item Cute Dog Image Version 0.1
if (!empty($settings['show_gender']) && $message['member']['dog'] != '')
     echo'
                                <li class="im_icons">', $message['member']['dog'], '</li>';
--- End code ---

I do get the result but not the way I want it displayed. See picture to understand.

The Craw:
If you could please attach your display.template.php file, that would be a help.

Navigation

[0] Message Index

[#] Next page

Go to full version