Created one new page - MyMood (by RateU)
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #1
Created one new page - MyMood (by RateU)
Hello guys.
I have just changed some items to put the mood in the "USERNAME Forum Info" table. Then I created one page to change the MyMood that RateU created called MyMood.php and the template called MyMood.

[Image: semttulonl.png]

Once the user clicks the MyMood image it will popup the MyMood template/page and the user will be able to select the Mood within the dropdown menu. Once the user select the mood he can close the page and click the "refresh" image seen next the "My Mood:" field. This button will refresh the page to make the new Mood appear in the profile. The MyMood page is also linked to the user "Aditional information" field inside his "edit profile" link (User control panel).

[Image: 69339214.png]

But... Once the user click to change the mood again the MyMood page will not display the current selected MyMood. How can I add to the dropdown menu show the selected MyMood? (the "Aditional information" field inside his "edit profile" link (User control panel) shows the selected mood.)


MyMood.php (Template)

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<html>
<head>
<title>{$mybb->settings['bbname']} - My Mood</title>
{$headerinclude}
</head>
<body>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="trow1" align="center">
<br />
<br />
<strong>Change My Mood</strong>
<form action="usercp.php" method="post" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<blockquote>Select your current Mood from the list bellow.</blockquote>
<br />
<br />
<span class="smalltext">My Mood:</span>
<br />
<select name="profile_fields[fid10]" size="1">
<option value="Aggressive">Aggressive</option>
<option value="Alienated">Alienated</option>
<option value="Amazed">Amazed</option>
<option value="Amused">Amused</option>
<option value="Angelic">Angelic</option>
<option value="Angry">Angry</option>
<option value="Apelike">Apelike</option>
<option value="Artistic">Artistic</option>
<option value="Asleep">Asleep</option>
<option value="Balanced">Balanced</option>
<option value="Banhappy">Banhappy</option>
<option value="Bashful">Bashful</option>
<option value="Bitching">Bitching</option>
<option value="Blah">Blah</option>
<option value="Bookworm">Bookworm</option>
<option value="Bored">Bored</option>
<option value="Breezy">Breezy</option>
<option value="Brooding">Brooding</option>
<option value="Busy">Busy</option>
<option value="Buzzed">Buzzed</option>
<option value="CaffeineFix">CaffeineFix</option>
<option value="Chatty">Chatty</option>
<option value="Cheeky">Cheeky</option>
<option value="Cheerful">Cheerful</option>
<option value="Cloud9">Cloud9</option>
<option value="Cold">Cold</option>
<option value="Coldturkey">Coldturkey</option>
<option value="Confused">Confused</option>
<option value="Cool">Cool</option>
<option value="Crappy">Crappy</option>
<option value="Creative">Creative</option>
<option value="Curious">Curious</option>
<option value="Cynical">Cynical</option>
<option value="Daring">Daring</option>
<option value="Dead">Dead</option>
<option value="Depressed">Depressed</option>
<option value="Devilish">Devilish</option>
<option value="Disagree">Disagree</option>
<option value="Doh">Doh</option>
<option value="Doubtful">Doubtful</option>
<option value="Dramaqueen">Dramaqueen</option>
<option value="Dreaming">Dreaming</option>
<option value="Drunk">Drunk</option>
<option value="Elated">Elated</option>
<option value="Energetic">Energetic</option>
<option value="Fiendish">Fiendish</option>
<option value="Fine">Fine</option>
<option value="Flirty">Flirty</option>
<option value="Gloomy">Gloomy</option>
<option value="Goofy">Goofy</option>
<option value="Grumpy">Grumpy</option>
<option value="Happy">Happy</option>
<option value="Hot">Hot</option>
<option value="Hungover">Hungover</option>
<option value="InLove">InLove</option>
<option value="Innocent">Innocent</option>
<option value="Inpain">Inpain</option>
<option value="Insomnious">Insomnious</option>
<option value="Inspired">Inspired</option>
<option value="Lonely">Lonely</option>
<option value="Lucky">Lucky</option>
<option value="Lurking">Lurking</option>
<option value="Mellow">Mellow</option>
<option value="Mischievious">Mischievious</option>
<option value="Mondayblues">Mondayblues</option>
<option value="Musical">Musical</option>
<option value="Nerdy">Nerdy</option>
<option value="Notamused">Notamused</option>
<option value="Notworthy">Notworthy</option>
<option value="Paranoid">Paranoid</option>
<option value="Pensive">Pensive</option>
<option value="Predatory">Predatory</option>
<option value="Procrastinating">Procrastinating</option>
<option value="Psychedelic">Psychedelic</option>
<option value="Question">Question</option>
<option value="Relaxed">Relaxed</option>
<option value="Roflmao">Roflmao</option>
<option value="Sad">Sad</option>
<option value="Scared">Scared</option>
<option value="Scurvy">Scurvy</option>
<option value="Shocked">Shocked</option>
<option value="Sick">Sick</option>
<option value="Sleepy">Sleepy</option>
<option value="Sluggish">Sluggish</option>
<option value="Sneaky">Sneaky</option>
<option value="Snobbish">Snobbish</option>
<option value="Spaced">Spaced</option>
<option value="Spooky">Spooky</option>
<option value="Sporty">Sporty</option>
<option value="Starving">Starving</option>
<option value="Stressed">Stressed</option>
<option value="Sunshine">Sunshine</option>
<option value="Sweettooth">Sweettooth</option>
<option value="Thinking">Thinking</option>
<option value="Tired">Tired</option>
<option value="Torn">Torn</option>
<option value="Twisted">Twisted</option>
<option value="Veggedout">Veggedout</option>
<option value="Volatile">Volatile</option>
<option value="Woot">Woot</option>
<option value="Worried">Worried</option>
<option value="Yeehaw">Yeehaw</option>
</select>
</td>
<br />
<br />
<tr>
<td>
<div align="center">
<input type="hidden" name="action" value="do_profile" />
<input type="submit" class="button" name="regsubmit" value="Update Profile" />
</div>
</td>
</tr>
</form>
</td>
</tr>
</table>
</body>
</html>


MyMood.php (File itself)

Code:
1
2
3
4
5
6
7
8
9
10
11
<?php

define('IN_MYBB', 1); // (1a)
require "./global.php"; // (1b)

add_breadcrumb("MyMood", "MyMood.php"); // (2)

eval("\$MyMood = \"".$templates->get("MyMood")."\";"); // (3)
output_page($MyMood); // (4)

?>


Thank you. Smile


[Image: 468x602b.png]
(This post was last modified: 11-28-2010 12:46 AM by Skiilz.)
11-28-2010 12:46 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: Created one new page - MyMood (by RateU)
(11-28-2010 12:46 AM)Skiilz Wrote:  I have just changed some items to put the mood in the "USERNAME Forum Info" table

What do you mean by "USERNAME Forum Info table"?

11-28-2010 04:44 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #3
RE: Created one new page - MyMood (by RateU)
The first profile table in the left:

Code:
1
2
3
4
5
6
Skiilz's Forum Info
Joined: 	11-16-2010
Last Visit 	Today 07:42 AM
Total Posts: 	100 (8.22 posts per day | 2.98 percent of total posts)
(Find All Threads — Find All Posts)
Time Spent Online: 	1 Day, 38 Minutes, 59 Seconds


[Image: 468x602b.png]
(This post was last modified: 11-28-2010 07:43 AM by Skiilz.)
11-28-2010 07:43 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Created one new page - MyMood (by RateU)
Are you using PHP In Template plugin or Template Conditional plugin?

11-28-2010 07:49 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #5
RE: Created one new page - MyMood (by RateU)
MyMood page: none;
MyMood on profile: Template Conditional (same as your tutorial)

[Image: 468x602b.png]
11-28-2010 08:12 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Created one new page - MyMood (by RateU)
(11-25-2010 08:05 AM)Skiilz Wrote:  P.S.: As stated here (http://community.mybb.com/thread-82787.html

I asked it to you because in this post you are using PHP In Template plugin.
Please remember that you need a different code for the MyBB Hacks Mood if you are using PHP In Template.

(11-28-2010 12:46 AM)Skiilz Wrote:  How can I add to the dropdown menu show the selected MyMood?

I think you can use conditional for that.
Try to add this kinds of code in each option there:

Code:
<option value="Aggressive"<if $mybb->user['fid10'] == 'Aggressive' then> selected="selected"</if>>Aggressive</option>


11-28-2010 08:37 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #7
RE: Created one new page - MyMood (by RateU)
Plugin I have: PHP and Template Conditionals
Thank you that worked. Took me some minutes to add this code to all of the items Smile

[Image: 468x602b.png]
11-28-2010 09:56 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Created one new page - MyMood (by RateU)
(11-28-2010 09:56 AM)Skiilz Wrote:  Plugin I have: PHP and Template Conditionals

I hope you've changed the code for the mood system to make it supported by PHP In Template 1.7 plugin "officially" (I think).

11-29-2010 02:52 AM
Find all posts by this user Quote this message in a reply
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #9
RE: Created one new page - MyMood (by RateU)
SO.. I have to change this:

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


to this:

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>

?


[Image: 468x602b.png]
11-29-2010 03:15 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #10
RE: Created one new page - MyMood (by RateU)
I think you should do that.
Not quite sure if using <?=.....?> supported officially by PHP In Template plugin (at least for 1.7).

11-29-2010 06:19 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: