I am using the user badges module and while I have that working correctly, what I would like to do is place my badge (currently a star) in a different place.

Right now it shows ...

Submitted by Username on 17 October 2006 - 6:17pm.
[image of star appears here]

What I would like is ...

Submitted by Username [image of star appears here] on 17 October 2006 - 6:17pm.

Though I would settle for ...

Submitted by Username on 17 October 2006 - 6:17pm. [image of star appears here]

With the star inline with the submitted by line.

I'm working with my node.tpl.php file and this is what I've got:


<div class="node<?php if ($sticky) { print " sticky"; } ?>">
<?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?><div class="nodecontent"><?php if ($picture) { print $picture; }?>
<span class="taxonomy"><?php print $terms?></span>
<div class="submitted"><?php print $submitted?>
<?php if (module_exist('user_badges') ) { print user_badges_for_uid($uid); }?>
</div>
<div class="content"><?php print $content?></div>
<?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>
</div>
</div>

Comments

pbarnett’s picture

Hi!

You could try

<?php if (module_exist('user_badges') ) { $badge = user_badges_for_uid($uid); ?>
<?php $submitted = preg_replace('/ on /'," $badge on ", $submitted); } ?>
<div class="submitted"><?php print $submitted?></div>

Pete.

Kornika’s picture

Not like I want it too ...

Now it displays as ...

Submitted by Kornika
[image of star]
on 16 October 2006 - 7:45pm.

On three separate lines.

Thanks for your response!

-Kornika

pbarnett’s picture

Hi, Kornika.

Could you post the generated HTML for the 'Submitted by' part of the page? On my pages, it looks like this (I don't have user_badges working as I use filemanager rather than the upload module, so can't test it) :-

<td class="whcnt"><small>Submitted by admin [insert] on Thu, 21/09/2006 - 14:56.</small></td>

It should be possible to fix the problem if we could see what's actually happening...

Looking at the module source, function theme_user_badge($badge) could be overridden if you're using a phptemplate-based theme, so that's another possibility...

Pete.

Kornika’s picture

Pete-

Thanks for your input however, by lots (and lots) of trial and error I figured it out.

I'd post it here, but I really don't know what I did. I just kept tweaking the PHP until I got it.

Thanks anyway!

-Kornika

pbarnett’s picture

...is remembering what you did ;-)

Pete.

Anonymous’s picture

Hi - If I wanted the badge to appear in front of the username, with everything all in line, how would I do that? Thanks so much!

tknospdr’s picture

I just installed user badges to test them out and they don't show up at all on my site.

Thanks,
David

EDIT - never mind, I totally forgot that you have to add code to the php of the site files to make the badges show up. I haven't done that yet.