Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Favorite Football Club
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Favorite Football Club
Very similar to MyBB Hacks Mood. This time, we will try to use that "trick" for Favorite Football Club.

We need Template Conditionals plugin or PHP in Templates / Complex Templates plugin to do this, and "combine" it with Custom Profile Fields.

In this example, we use Custom Profile Fields ID = 5 (I want to make it different with Mood). The Football Club logo images is png images (modify it as our needs), in images/flogo folder/directory (modify it as our needs too).

  1. Create a custom profile fields with these settings:
    • Title: Favorite Football Club
    • Short Description: Your favorite football club.
    • Field Type: Select Box
    • Field Length: 1
    • Selectable Options?:

      Code:
      Manchester United
      Real Madrid
      Liverpool

      Modify it as our needs. It can be loooong list Biggrin

  2. Upload football club logo images. Naming the images should be similar to Mood images. Example (based on the football clubs above):
    • Football Club: Manchester United
      Football Club Logo Image: ManchesterUnited.png
    • Football Club: Real Madrid
      Football Club Logo Image: RealMadrid.png
    • Football Club: Liverpool
      Football Club Logo Image: Liverpool.png
  3. Displaying the user's favorite football club:
    • In Postbit:
      Put this code in our postbit_author_user template:
      For Template Conditionals plugin:

      HTML Code
      <if $post['fid5'] then>
      	<div>
      		<img src="images/flogo/<?=str_replace(' ', '', $post['fid5'])?>.png" alt="{$post['fid5']}" title="Favorite Football Club: {$post['fid5']}" />
      	</div>
      </if>


      For PHP in Templates / Complex Templates plugin:

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

      Modify it as our needs. Please remember that we use custom profile field id = 5 for this example. If we use other id, we need to change it.

      As an alternative, we can put it in our postbit and postbit_classic template too, if we already had to many stuff in our postbit_author_user template.

    • In Profile:
      member_profile_customfields_field template.
      For Template Conditionals plugin:

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      <if $customfield['fid'] == 5 then>
      	<if $userfields['fid5'] != '' then>
      		<tr>
      			<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
      			<td class="{$bgcolor}" width="60%"><img src="images/flogo/<?=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>


      For PHP in Templates / Complex Templates plugin:

      HTML Code
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      <if $customfield['fid'] == 5 then>
      	<if $userfields['fid5'] != '' then>
      		<tr>
      			<td class="{$bgcolor}" width="40%"><strong>{$customfield['name']}:</strong></td>
      			<td class="{$bgcolor}" width="60%"><img src="images/flogo/<?php echo 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. If we are using it with the mood, maybe we need to use <elseif> or array for that.

      If we want to display the logo in member_profile template, we can use this code:
      For Template Conditionals plugin:

      HTML Code
      <if $userfields['fid5'] != '' then>
      	<img src="images/flogo/<?=htmlspecialchars_uni(str_replace(' ', '', $userfields['fid5']))?>.png" alt="<func htmlspecialchars_uni>{$userfields['fid5']}</func>" title="Favorite Footbal Club: <func htmlspecialchars_uni>{$userfields['fid5']}</func>" />
      </if>


      For PHP in Templates / Complex Templates plugin:

      HTML Code
      <if $userfields['fid5'] != '' then>
      	<img src="images/flogo/<?php echo htmlspecialchars_uni(str_replace(' ', '', $userfields['fid5'])); ?>.png" alt="<func htmlspecialchars_uni>{$userfields['fid5']}</func>" title="Favorite Footbal Club: <func htmlspecialchars_uni>{$userfields['fid5']}</func>" />
      </if>



Very similar to the mood "trick".
Please tell me if I had made a mistake with the code. I'm still learning Biggrin

Live Demo:
Postbit:
http://www.14.mynie.co.cc/showthread.php?tid=205
Profile:
http://www.14.mynie.co.cc/member.php?act...http://www.14.mynie.co.cc/member.php?action=profile&uid=


Attached File(s) Thumbnail(s)
       

12-12-2010 06:14 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Favorite Football Club - RateU - 12-12-2010 06:14 AM
RE: Favorite Football Club - ZiNgA BuRgA - 12-12-2010, 09:35 AM
RE: Favorite Football Club - Imran - 12-13-2010, 03:02 AM
RE: Favorite Football Club - RateU - 12-13-2010, 04:54 AM

 Standard Tools
Forum Jump: