Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 MyBB Hacks Mood System
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
MyBB Hacks Mood System
Because some plugin developer really like using My as prefix for their plugin, we will use MyBB Hacks as prefix for this modification Biggrin
So, we can call it as MyBB Hacks Mood System Biggrin

Not too hard to do this, because we have the amazing tools, conditional in template.
So, to do this, we need Template Conditionals plugin or PHP in Templates / Complex Templates plugin. We will "combine" it with Custom Profile Fields.

The mood can be selected in UserCP -> Edit Profile.
The mood can be displayed in several area, like Postbit, Member Profile, Header (Member Panel) and Member List.

Here is how to do that:
In this example, we use Custom Profile Fields ID = 4. The mood images is png images, in images/mybbhacksmood folder/directory. So, maybe we need to modify it as our needs.
  1. Create a custom profile fields with these settings:
    • Title: Mood
      Modify it as our needs.
    • Short Description: Your mood today. You can edit your mood whenever you want by visiting this page.
      Modify it as our needs.
    • Field Type: Select Box
    • Field Length: 1
    • Selectable Options?:

      Code:
      Happy
      Sad
      In Love

      Modify it as our needs.

  2. Upload mood images. For the example mood above:
    • Mood: Happy
      Mood Image: Happy.png
    • Mood: Sad
      Mood Image: Sad.png
    • Mood: In Love
      Mood Image: InLove.png
  3. Now, we will displaying the MyBB Hacks Mood.
    • In Postbit:
      Put this code in our postbit_author_user template:

      HTML Code
      <if $post['fid4'] then>
      	<div>
      		Mood: <img src="images/mybbhacksmood/<?=str_replace(' ', '', $post['fid4'])?>.png" alt="{$post['fid4']}" title="{$post['fid4']}" />
      	</div>
      </if>

      Modify it as our needs. Change the 4 to our MyBB Hacks Mood custom profile fields id.
      Or, we can put it in our postbit and postbit_classic template.

    • In Profile:
      member_profile_customfields_field template.
      If we didn't modified this template before, replace the template contents with:

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      <if $customfield['fid'] == 4 then>
      	<if $userfields['fid4'] != '' then>
      		<tr>
      			<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
      			<td class="{$bgcolor}" width="60%"><img src="images/mybbhacksmood/<?=str_replace(' ', '', $customfieldval)?>.png" alt="{$customfieldval}" title="{$customfieldval}" /></td>
      		</tr>
      	</if>
      <else>
      	<tr>
      		<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
      		<td class="{$bgcolor}" width="60%">{$customfieldval}</td>
      	</tr>
      </if>

      Modify it as our needs. Change the 4 to our MyBB Hacks Mood custom profile fields id. If a user didn't select any mood, the MyBB Hacks Mood column will not be displayed.

    • In Header:
      Put this code in our header_welcomeblock_member template:

      HTML Code
      <if $mybb->user['fid4'] then>
      	<div>
      		Mood: <img src="images/mybbhacksmood/<?=htmlspecialchars_uni(str_replace(' ', '', $mybb->user['fid4']))?>.png" alt="<?=htmlspecialchars_uni($mybb->user['fid4'])?>" title="<?=htmlspecialchars_uni($mybb->user['fid4'])?>" />
      	</div>
      </if>

      Modify it as our needs. Change the 4 to our MyBB Hacks Mood custom profile fields id.
      BTW, do you think other Mood System has this feature (displaying mood in header template)? MyBB Hacks Mood System is the pioneer Biggrin

    • In Member List:
      Put this code in our memberlist_user template:

      HTML Code
      <if $user['fid4'] then>
      	<div>
      		Mood: <img src="images/mybbhacksmood/<?=htmlspecialchars_uni(str_replace(' ', '', $user['fid4']))?>.png" alt="<?=htmlspecialchars_uni($user['fid4'])?>" title="<?=htmlspecialchars_uni($user['fid4'])?>" />
      	</div>
      </if>

      Modify it as our needs. Change the 4 to our MyBB Hacks Mood custom profile fields id.
      Again, do you think other Mood System has this feature (displaying mood in member list page)? MyBB Hacks Mood System is the pioneer again Biggrin



That's it. Please tell me if I did something wrong Biggrin

Note: For PHP In Template plugin, the code is a bit different.

11-22-2010 09:53 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #2
RE: MyBB Hacks Mood System
Thank you Smile
I was trying to do it by myself... Almost did it!

I modified the code to show a message if no mood selected:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<if $customfield['fid'] == 10 then>
	<if $userfields['fid10'] != '' then>
		<tr>
			<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
			<td class="{$bgcolor}" width="60%"><img src="images/mybbhacksmood/<?=str_replace(' ', '', $customfieldval)?>.gif" alt="{$customfieldval}" title="{$customfieldval}" /></td>
		</tr>

        <else>
		<tr>
			<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
			<td class="{$bgcolor}" width="60%">No Mood Selected</td>
		</tr>
	</if>
<else>
	<tr>
		<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
		<td class="{$bgcolor}" width="60%">{$customfieldval}</td>
	</tr>
</if>


[Image: 468x602b.png]
11-22-2010 10:32 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: MyBB Hacks Mood System
Thanks for the guide RateU!

My Blog
11-22-2010 11:16 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #4
RE: MyBB Hacks Mood System
Arrrggghhhh....(flail)....I don't have the Template Conditionals - just the Php in templates.... I shall try - looks very cool and we can use this for more things I think Smile


[Image: leelink.gif]
MYBB1.6 & XThreads
11-22-2010 11:25 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #5
RE: MyBB Hacks Mood System
I think the main thing that needs to be changed is this:
For every

Code:
<?= ... ?>

you see, replace with

Code:
<?php echo ...; ?>

(don't forget the semi-colon there)

Maybe I'll add something to the PHP in Templates plugin like that.


My Blog
(This post was last modified: 11-22-2010 11:34 AM by ZiNgA BuRgA.)
11-22-2010 11:33 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #6
RE: MyBB Hacks Mood System
Thanks Zinga Smile


[Image: leelink.gif]
MYBB1.6 & XThreads
11-22-2010 12:06 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: MyBB Hacks Mood System
(11-22-2010 11:16 AM)ZiNgA BuRgA Wrote:  Thanks for the guide RateU!
Biggrin Thanks, Yumi.

(11-22-2010 10:32 AM)Skiilz Wrote:  I modified the code to show a message if no mood selected:

Yeah. We can use image for no mood too.

(11-22-2010 11:25 AM)leefish Wrote:  I don't have the Template Conditionals - just the Php in templates....

I'm using PHP In Template too, Lee. We can change the part of the code that Yumi said.
Example for postbit:

HTML Code
<if $post['fid4'] then>
	<div>
		Mood: <img src="images/mybbhacksmood/<?=str_replace(' ', '', $post['fid4'])?>.png" alt="{$post['fid4']}" title="{$post['fid4']}" />
	</div>
</if>


We can change it to:

HTML Code
<if $post['fid4'] then>
	<div>
		Mood: <img src="images/mybbhacksmood/<?php echo str_replace(' ', '', $post['fid4']); ?>.png" alt="{$post['fid4']}" title="{$post['fid4']}" />
	</div>
</if>

Like Yumi said, don't forget the semicolon there.


11-23-2010 04:58 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #8
RE: MyBB Hacks Mood System
In my test forums the mood image alt link is showing like this:
http://mysite.com/images/MyMood/.gif

[Image: 468x602b.png]
12-01-2010 03:27 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #9
RE: MyBB Hacks Mood System
(12-01-2010 03:27 AM)Skiilz Wrote:  In my test forums the mood image alt link is showing like this:
http://mysite.com/images/MyMood/.gif

Could you give more info?
What do you mean by "image alt link"?
In which page/template?
What code you put in that template?
Link to your test forum?

12-01-2010 03:55 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #10
RE: MyBB Hacks Mood System
I set the alt="MyMood" to see if the error was with the image then if I right click the alt property of the image and select "copy image link" it shows the http://mysite.com/images/MyMood/.gif :/

member_profile

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- Start Mood !-->
<if $userfields['fid7'] != '' then>
<a href="javascript:;" value="Reload Page" onClick="window.location.reload()"><img src="{$mybb->settings['bburl']}/refresh.png" alt="Refresh" title="Refresh Mood" /></a>
&nbsp;<strong>MyMood:</strong> 
<if $GLOBALS['mybb']->user['uid'] == $memprofile['uid'] then>
<a href="javascript:;" onclick="MyBB.popupWindow('MyMood.php', 'imcenter', 450, 300);"><img src="images/MyMood/<?=str_replace(' ', '', $customfieldval)?>.gif" alt="MyMood" title="Click to change your Mood." valign="middle" /></a>
<else>
<img src="images/MyMood/<?=str_replace(' ', '', $customfieldval)?>.gif" alt="MyMood" title="{$memprofile['username']} is {$customfieldval}" valign="middle" />
</if>
<else>
No Mood Selected.
</if>
<!-- End Mood !-->


[Image: 468x602b.png]
(This post was last modified: 12-01-2010 05:07 AM by Skiilz.)
12-01-2010 05:06 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: