MyBB Community Forums

Full Version: [Release] Small quotes and code blocks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is a simple plugin inspired by Ryan Loos that enables you to make the default font size of quotes and code blocks smaller across your site. This is useful to reduce the size of quoted text and therefore make your site more user friendly.

You can specify the font size and whether it applies to only code, only quotes or both in the settings.

This will only effect the normal size of the text so if a text has been formatted to be larger or smaller already with myCode it will be unaffected.

Licensed under GNU/GPL.
finally, there is plugins without touching the original theme (manually) Wink
No problem, this can be done with CSS as well which would probably be a tidier approach but not everyone likes mucking around with code.
Thank you TimB. Its very nice.
You need to familiarize yourself with how MyBB works to efficiently create code.

function small_quote($message)
{
global $db;
$query = $db->simple_select("settings", "*", "name='smallquotequote'");
$quotevalue = $db->fetch_field($query, "value");

$query = $db->simple_select("settings", "*", "name='smallquotecode'");
$codevalue = $db->fetch_field($query, "value");

$query = $db->simple_select("settings", "*", "name='smallquotesize'");
$quotetextsize = $db->fetch_field($query, "value");

if($quotevalue == 1){
$message = str_ireplace("<blockquote>", "<blockquote style=\"font-size: ".$quotetextsize.";\">", $message);
$message = str_ireplace("<cite>", "<cite style=\"font-size: 1.2em;\">", $message);
}
if($codevalue == 1){
$message = str_ireplace("<code>", "<code style=\"font-size: ".$quotetextsize.";\">", $message);
}

return $message;
}

Should be

function small_quote($message)
{
global $mybb;

if($mybb->settings['smallquotequote']){
$message = str_ireplace("<blockquote>", "<blockquote style=\"font-size: ".$mybb->settings['smallquotesize'].";\">", $message);
$message = str_ireplace("<cite>", "<cite style=\"font-size: 1.2em;\">", $message);
}
if($mybb->settings['smallquotecode']){
$message = str_ireplace("<code>", "<code style=\"font-size: ".$mybb->settings['smallquotesize'].";\">", $message);
}

return $message;
}

You added 3 queries for no reason. Use the $mybb global.

Also to be blunt..this shouldn't be a plugin. The correct method is to alter the theme CSS in the admincp. The code and quote css are defined under global as blockquote and blockcode.
Thanks labrocca, I was looking at various other plugins for techniques and obviously I picked a bad example. That makes things a lot easier cheers Smile
What you can do to view some variables is simpley create your plugin then add some print_r() statements to see what is passed.

print_r($mybb);

That will give you a great idea of what's in there. You'll need to view source of course to see the array properly. Stuff like $user, $post, or $message also gets passed in hooks if you add them to your global statement.

The best way to create plugins is to utilize what mybb already has to offer in terms of hooks, variables, javascript and functions. The library built into MyBB is fairly extensive but unfortunately isn't documented very well.
Thanks for that idea, I'll do that now.

Can you (or anyone else) suggest a plugin that is a good example to study the source code of? I have a MyBB central subscription so either yours or someone elses. I am still a bit confused about what the correct way to modify a template with a plugin is.

Edit: I found some code on php.net that outputs a nicely formatted list of the object properties, here is the code, http://community.mybboard.net/thread-655...70912.html
so is the plugin ok to use ?
Thanks
Which one, the original one in this thread or the one I posted code to in the post above yours?
Pages: 1 2