MyBB Community Forums

Full Version: First plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey - I decided to start attempting my own first plugin.

I basically need to have an option in the plugins settings called "css" where the admin can change the css of the object.

For example the admin could input whatever css they liked to create an image such as a rounded rectangle. How could I do this?

Thanks
(2012-06-09, 11:39 AM)vernier Wrote: [ -> ]Hey - I decided to start attempting my own first plugin.

I basically need to have an option in the plugins settings called "css" where the admin can change the css of the object.

For example the admin could input whatever css they liked to create an image such as a rounded rectangle. How could I do this?

Thanks

Try here http://www.w3schools.com/css/css_examples.asp
Oh sorry I didn't mean how could they create a rounded rectangle, I meant a setting in the plugin for a textarea, which I have, but I don't know how to change the css to the value of that textbox.

Thanks anyway Smile
Assuming you only need to style a specific element, you could do something like this when outputting the code:

<div style="{$mybb->settings['plugin_css']}"></div>

plugin_css being the name of the setting. If the user inputs something like this into the textarea:

background: #ff0000; width: 200px; color: #000;

Then it would then result in this:

<div style="background: #ff0000; width: 200px; color: #000;"></div>
Do you mean you want to add a setting in the ACP Plugin settings for the css of the div you are making? The Board messages plugin from the mybb site does that - perhaps look at how that works.
Works a charm - cheers Fabio!

How do you add a settings link here:

[Image: d851c40c12da42e0a9894d3.png]

Cheers again! Big Grin

Also the last thing im unsure of is what is the code to modify a template?

Such as add

<script type="text/javascript">Javascript here</script>

to say the headerinclude template, how would I do this?

Thanks! Smile
Did you tried looking another similar plugins? You'd understand well if you look at them.
I had a look at one and found this:

 //Archivo requerido para reemplazo de plantillas
	require "../inc/adminfunctions_templates.php";
    //Reemplazos que vamos a hacer en las plantillas 1.- Platilla 2.- Contenido a Reemplazar 3.- Contenido que reemplaza lo anterior
	find_replace_templatesets('headerinclude', '#"Content-Script-Type" content="text\/javascript" \/>#', '"Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/ventana_flotante.js"></script>');
    find_replace_templatesets("header_welcomeblock_guest", '#'.preg_quote('</script>').'#', '</script>{$ventana_flotante}');
    //Se actualiza la info de las plantillas
	$cache->update_forums();

    return true;

Is that anything to do with it?
Maybe not what you want as a answer, but have you tried a READM.txt file specifying to copy some CSS code to the already existing global.css (this way it will be theme dependent) file instead of a general setting for it?
I don't know how far you have got with the plugin, but you could try looking at ZB's tutorial. It is a bit outdated now, but it covers the general idea pretty well.

http://mybbhacks.zingaburga.com/showthread.php?tid=74
Pages: 1 2