MyBB Hacks

Full Version: Different Smilies for Different Themes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This simple modification will allow you to have different smilies for different themes.
Note that, this, being an addition means that old smilies which are common across all themes will work fine.

Okay, firstly, open up /inc/class_parser.php,
Find:

PHP Code:
		global $cache;
		$this->smilies_cache = array();

		$smilies = $cache->read("smilies");
		if(is_array($smilies))
		{
			foreach($smilies as $sid => $smilie)
			{
				$this->smilies_cache[$smilie['find']] = "<img src=\"{$this->base_url}{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";

Replace with:

PHP Code:
		global $cache, $theme;
		$this->smilies_cache = array();

		$smilies = $cache->read("smilies");
		if(is_array($smilies))
		{
			foreach($smilies as $sid => $smilie)
			{
				$smilie['image'] = str_replace('{theme}', $theme['imgdir'], $smilie['image']);
				$this->smilies_cache[$smilie['find']] = "<img src=\"{$this->base_url}{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";


Also, open up misc.php,
Find: (2 occurances)

PHP Code:
$smilie['find'] = htmlspecialchars_uni($smilie['find']);

Add below: (2 occurances)

PHP Code:
$smilie['image'] = str_replace('{theme}', $theme['imgdir'], $smilie['image']);


Finally, open up inc/functions.php,
Find:

PHP Code:
$smiliecache[$smilie['find']] = $smilie['image'];

Replace with:

PHP Code:
$smiliecache[$smilie['find']] = str_replace('{theme}', $theme['imgdir'], $smilie['image']);


Now, upload smilies that you want to be different for each theme into your /images/<themedir>/smilies/ folder, for each theme.
Finally, go to your AdminCP -> Message Filters -> Smilie Manager and edit the Image Path of the smilies that you want to be different across all themes.
Just replace images with {theme} and update.  For example, the default Smile is:

Code:
images/smilies/smile.gif

If you want it to be different across themes, just change it to:

Code:
{theme}/smilies/smile.gif

(and don't forget to upload all the smilies to the appropriate location)


Edit: Updated

Thanks!

This comes in handy for when you have smilies that match only a certain theme, for example Christmas smilies are best used only in the Christmas theme and so on.
I will take note of the codes and other information for smilies.Later i will try it and share to my friends as well.
Reference URL's