MyBB Community Forums
[Release] Small quotes and code blocks - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Releases (https://community.mybb.com/forum-102.html)
+---- Thread: [Release] Small quotes and code blocks (/thread-62428.html)

Pages: 1 2


[Release] Small quotes and code blocks - Tim B. - 2010-01-02

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.


RE: [Release] Small quotes and code blocks - FBI - 2010-01-02

finally, there is plugins without touching the original theme (manually) Wink


RE: [Release] Small quotes and code blocks - Tim B. - 2010-01-04

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.


RE: [Release] Small quotes and code blocks - Lo. - 2010-01-04

Thank you TimB. Its very nice.


RE: [Release] Small quotes and code blocks - labrocca - 2010-01-04

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.


RE: [Release] Small quotes and code blocks - Tim B. - 2010-01-05

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


RE: [Release] Small quotes and code blocks - labrocca - 2010-01-05

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.


RE: [Release] Small quotes and code blocks - Tim B. - 2010-01-05

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-65551-post-470912.html


RE: [Release] Small quotes and code blocks - Technoman - 2010-02-27

so is the plugin ok to use ?
Thanks


RE: [Release] Small quotes and code blocks - Tim B. - 2010-02-27

Which one, the original one in this thread or the one I posted code to in the post above yours?