MyBB Community Forums

Full Version: [Tutorial] How to set a default post icon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
INTRODUCTION:

In this tutorial I will be showing you how to set a default post icon for all threads, but still allow users to pick another icon if they want. Very simple.

TUTORIAL:

1. Go to Admin CP > Configuration > Post Icons.

2. Hover over Edit in the corresponding row of the default post icon you want to use.

3. In the end of the link there will be &iid=2 whereas 2 is the id of that specific post icon.

[attachment=21926]

4. Go to Admin CP > Templates & Style > Templates > Your template set > Ungrouped Templates > posticons.

5. Replace all the code inside the posticons template with the code below, using the id you found in step 3 instead of {example}:

<tr>
<td class="trow1" style="vertical-align: top"><strong>{$lang->post_icon}</strong></td>
<td class="trow1" valign="top" colspan="2">{$iconlist}<input type="radio" class="radio" name="icon" value="{example}" checked="checked" style="display: none;" /></td>
</tr>

6. In order to update all existing threads to use the same post icon, execute this SQL query (by replacing X with the icon ID you found in step 3):

UPDATE `mybb_threads` SET `icon` = 'X' WHERE `icon` = '';

7. In order to update all existing posts to use the same post icon, execute this SQL query (by replacing X with the icon ID you found in step 3):

UPDATE `mybb_posts` SET `icon` = 'X' WHERE `icon` = '';

CONCLUSION:

In the end, on a New Thread or New Reply page you will see something like the image below. Basically, we removed the "no icon" option from the left and added an invisible option which is checked by default. If the user doesn't select another post icon then it will use the post icon from the invisible option.

[attachment=21925]
Great! So that field is now all consistent, thanks Faviouz!
thanks a lot dear very nice
Seems not working here: http://www.phwebmaster.net Undecided
its working, thanks Smile
(2011-03-12, 10:31 PM)Fábio Maia Wrote: [ -> ]5. Replace all the code inside the posticons template with the code below, using the id you found in step 3 instead of {example}:

<tr>
<td class="trow1" style="vertical-align: top"><strong>{$lang->post_icon}</strong></td>
<td class="trow1" valign="top" colspan="2">{$iconlist}<input type="radio" class="radio" name="icon" value="{example}" checked="checked" style="display: none;" /></td>
</tr>

Thanks for this tutorial. This technique is indeed very useful.

Nevertheless I would propose to insert the hidden icon option before the iconlist. Otherwise the hidden icon option would always overwrite the actual selected icon if e.g. the post is edited.

Example:

<tr>
<td class="trow1" style="vertical-align: top"><strong>{$lang->post_icon}</strong></td>
<td class="trow1" valign="top" colspan="2"><input type="radio" class="radio" name="icon" value="{example}" checked="checked" style="display: none;" />
{$iconlist}</td>
</tr>
Is there a way to get this working for a specific post icon in a specific forum, for multiple forums/subforums?