Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Release] Small quotes and code blocks
#1
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.


Attached Files Thumbnail(s)
       

.zip   smallquote.zip (Size: 1.89 KB / Downloads: 109)
Reply
#2
finally, there is plugins without touching the original theme (manually) Wink
Hello, Welcome to MyBB Indonesia to get local support
My 'Simple' Unique Plugin here Smile
Reply
#3
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.
Reply
#4
Thank you TimB. Its very nice.
I'm not here often, shoot a PM or whatever if you want my discord.
Reply
#5
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.
Reply
#6
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
Reply
#7
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.
Reply
#8
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
Reply
#9
so is the plugin ok to use ?
Thanks
Reply
#10
Which one, the original one in this thread or the one I posted code to in the post above yours?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)