Shortcodes, adding to the forum
From e107 Wiki
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
Adding Shortcodes to the ForumThe principles of adding shortcodes to the forum are much the same as adding them elsewhere; however there are some forum-specific codes. These are listed here.
You will need to identify the correct template file to edit - the defaults are in e107_plugins/forum/templates; however some themes override them with alternative files of the same names, in which case they will be in the theme directory. Probably forum_viewtopic_template.php will be what you want. Look at this in a text editor (even Notepad will do), and you should be able to see the correspondence with your forum layout. At line 89 in the default file is a line starting: $FORUMTHREADSTYLE = .... the text which follows sets the format of each post. It is a mix of HTML and shortcodes, so you do need to at least understand a bit of HTML. A little way down you will see: {EXTENDED=location.text}: {EXTENDED=location.value} this is displaying information from the extended user fields - location.text is the 'description', and location.value is the actual value. You can add fields in a similar format to pull out your other extended user fields. Adding a custom picture to the forumIt is possible to create a shortcode which displays a picture (or 'badge') against a user in the forum, dependent on the user class(es) they belong to. An example of this is the 'Support Team' picture used in the E107 forums. Creating the shortcodeCreate a file called 'xxxxx.sc' where xxxxx is the code you will be using to show the special picture (eg. support.sc). Put the following code into that page /*
* file support.sc
*/
// set global to $post_info for forum & $user for profile
global $post_info, $user;
// --> EDIT THE FOLLOWING <--
// use the following to list the classes with their pictures, from most important (1) to least important (4)
// this is the most important userclass
$rank_no1 = "Owner";
// this is the picture that needs to be showed with this userclass on forum/profile (examples used)
$rank_no1_pic = "<img src='".THEME_ABS."yourranks/owner.gif' />";
$rank_no2 = "Administrator";
$rank_no2_pic = "<img src='".THEME_ABS."yourranks/administrator.gif' />";
$rank_no3 = "Moderator";
$rank_no3_pic = "<img src='".THEME_ABS."yourranks/moderator.gif' />";
$rank_no4 = "Forum mod";
$rank_no4_pic = "<img src='".THEME_ABS."yourranks/forum_mod.gif' />";
// --> STOP EDIT <--
if(check_class($rank_no4, $post_info['user_class'], TRUE) || check_class($rank_no4, $user['user_class'], TRUE))
{
$output = "<div align='center'>$rank_no4_pic</div>";
}
if(check_class($rank_no3, $post_info['user_class'], TRUE) || check_class($rank_no3, $user['user_class'], TRUE))
{
$output = "<div align='center'>$rank_no3_pic</div>";
}
if(check_class($rank_no2, $post_info['user_class'], TRUE) || check_class($rank_no2, $user['user_class'], TRUE))
{
$output = "<div align='center'>$rank_no2_pic</div>";
}
if(check_class($rank_no1, $post_info['user_class'], TRUE) || check_class($rank_no1, $user['user_class'], TRUE))
{
$output = "<div align='center'>$rank_no1_pic</div>";
}
return $output;
// End of code extract
Once you have prepared this file, and the associated graphics, proceed as follows:
$sc_style['USER_SIGNATURE']['post'] = "</td></tr>";
$sc_style['SUPPORT']['pre'] = "<tr><td colspan='2' class='forumheader3' style='text-align:left'>"; $sc_style['SUPPORT']['post'] = "</td></tr>";
You're finished Further explanationJust take there are 3 userclasses (examples from e107) the e107 developers (highest rank within the classes) the e107 moderators (2nd rank within classes) the e107 support team (3rd rank within classes) If someone belongs to more than 1 group (eg 2dopey is both support and moderator), we want the picture for the highest rank within the classes to be showed. In the forums we want a picture of a moderator for 2dopey, not support as this is of a lower rank. I used the ranks to make the distinction as to what should be showed. If a developer is also a moderator, we want the picture of developer to show, not a moderator. Therefore a ranking of these classes is made within this script. | ||||||||

