MyBB Community Forums

Full Version: Add data to global.css with a Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sorry for my English Angel

I have a qustion, can i write css codes to global.css?
AdminCP > Themes & templates > click your theme > click global.php. Now go to the advanced tab and add your code on the bottom or change the sections you want.
@Aries-Belgium Thank You for your Post but i will add my codes with a plugin.
Why do you need a plugin?
(2011-04-29, 08:15 PM)Aries-Belgium Wrote: [ -> ]AdminCP > Themes & templates > click your theme > click global.php. Now go to the advanced tab and add your code on the bottom or change the sections you want.

Its global.css
(2011-05-01, 01:09 AM)Darth Stabro Wrote: [ -> ]Why do you need a plugin?

It doesnt matter why he needs a plugin to do it, thats what he wants to do.

What I normally do is create a new template add the additional css into that template, then call that template using a variable in the required template.

The following example will add the template to your "global templates", just add the css you want (Ive just placed some example css).

$css_template = array(
"title"		=> 'new_css',
"template"	=> $db->escape_string('
<style type="text/css">
.cssclass {
color:#000000;
font-size: 12px;
}
</style>
'),
"sid"		=> "-1",
"version"	=> "1.6",
"dateline"	=> TIME_NOW
);
$db->insert_query('templates', $css_template);

Then call that template, for example use a variable like so:
{$new_css}
Thank You @Janota
No problem Wink
//yeni css ekleme
	$stylesheet = '.board_message {
	background: #EFEFEF;
	color: #333333;
	border-top: 2px solid #D4D4D4;
	border-bottom: 2px solid #D4D4D4;
	padding: 5px;
	margin-top: 10px;
}';

	$new_stylesheet = array(
		'name'         => 'board_messages.css',
		'tid'          => 1,
		'attachedto'   => '',
		'stylesheet'   => $stylesheet,
		'lastmodified' => TIME_NOW
	);

	$sid = $db->insert_query('themestylesheets', $new_stylesheet);
	$db->update_query('themestylesheets', array('cachefile' => "css.php?stylesheet={$sid}"), "sid='{$sid}'", 1);

	$query = $db->simple_select('themes', 'tid');
	while($theme = $db->fetch_array($query))
	{
		require_once MYBB_ADMIN_DIR.'inc/functions_themes.php';
		update_theme_stylesheet_list($theme['tid']);
	}

	
	
//css silme
	$db->delete_query('themestylesheets', "name='board_messages.css'");

	$query = $db->simple_select('themes', 'tid');
	while($theme = $db->fetch_array($query))
	{
		require_once MYBB_ADMIN_DIR.'inc/functions_themes.php';
		update_theme_stylesheet_list($theme['tid']);
	}