MyBB Community Forums

Full Version: Replace forum logo?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What would the code be to replace a forum logo with a url that a person puts in via my plugin? Im thinking this?
Im sure I messed up big time codding here. Toungue But it IS 3AM
function ezlogo_insert(){
global $mybb;
if(intval($mybb->settings['ezlogo']) == 1){
find_replace_templatesets("header", "#".preg_quote("<img src="{\$theme['logo']}"")."#i", "What here????");
} 
} 
Try this;
function ezlogo_insert(){
global $mybb, $templates, $theme;
if(intval($mybb->settings['ezlogo']) == 1){
$theme['logo'] = "images/newlogo.gif";
} 
}

Didn't tested but I think it works.

Edit: Also use global_start hook for this function.
(2011-05-15, 06:54 AM)Yaldaram Wrote: [ -> ]Try this;
function ezlogo_insert(){
global $mybb, $templates, $theme;
if(intval($mybb->settings['ezlogo']) == 1){
$theme['logo'] = "images/newlogo.gif";
} 
}

Didn't tested but I think it works.

Edit: Also use global_start hook for this function.
Hmm, is it possible to make it so when the admin enters a url it will be place here.
"images/newlogo.gif";?

and Yeah I actually got the hook in first Big Grin slowly but surly getting there with this plugin making. Smile
Bump, can ya answer my last question please? Smile
here is my full code if it helps.

<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('global_start','ezlogo_insert');

function ezlogo_info()
{
	
	return array(
		"name"			=> "Ez Logo",
		"description"	=> "Adds a logo super easy!.",
		"website"		=> "http://mods.mybb.com",
		"author"		=> "Blake",
		"authorsite"	=> "http://mcmines.com",
		"version"		=> "1.2",
		"compatibility" => "14*,16*"
	);
}



function ezlogo_activate()
{
	global $db;
	require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
	$query = $db->simple_select("settinggroups", "COUNT(*) as rows");
	$rows = $db->fetch_field($query, "rows");

	$insertarray = array(
		'gid' => 'NULL', 
		'name' => 'ezlogo', 
		'title' => 'Ez Logo', 
		'description' => 'Add Logo\'\' url', 
		'disporder' => $rows+1, 
		'isdefault' => 'no'
	);
	$db->insert_query("settinggroups", $insertarray);
	$group['gid'] = $db->insert_id();
	
	
	$settings = array('name'        => 'ezlogo',
          'title'       => 'Ez Logo',
          'description' => 'Add Logo\'\' url',
          'optionscode' => 'yesno',
          'value'       => 'yes',
          'disporder'   => '100',
          'gid'         => $group['gid'],
           );

            $db->insert_query('settings', $settings);
	    
	    
	    $settings1 = array('name'        => 'ezlogo_url',
         'title'       => 'Url',
         'description' => 'Inserte logo\'\' Inseret logo url',
         'optionscode' => 'text',
         'value'       => 'http://',
         'disporder'   => '100',
         'gid'         => $group['gid'],
          );

            $db->insert_query('settings', $settings1);
}
function favicon_deactivate(){
	global $db;
	$db->delete_query("settings", "name='ezlogo'");
	$db->delete_query("settings", "name='ezlogo_url'");
	$db->delete_query("settinggroups", "name='ezlogo'");
}

function ezlogo_insert(){
global $mybb, $templates, $theme;
if(intval($mybb->settings['ezlogo']) == 1){
$theme['logo'] = "images/newlogo.gif";
} 
} 


?>
Replace the above with this;
<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('global_start','ezlogo_insert');

function ezlogo_info()
{
    
    return array(
        "name"            => "Ez Logo",
        "description"    => "Adds a logo super easy!.",
        "website"        => "http://mods.mybb.com",
        "author"        => "Blake",
        "authorsite"    => "http://mcmines.com",
        "version"        => "1.2",
        "compatibility" => "14*,16*"
    );
}



function ezlogo_activate()
{
    global $db;
    require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
    $query = $db->simple_select("settinggroups", "COUNT(*) as rows");
    $rows = $db->fetch_field($query, "rows");

    $insertarray = array(
        'gid' => 'NULL', 
        'name' => 'ezlogo', 
        'title' => 'Ez Logo', 
        'description' => 'Add Logo\'\' url', 
        'disporder' => $rows+1, 
        'isdefault' => 'no'
    );
    $db->insert_query("settinggroups", $insertarray);
    $group['gid'] = $db->insert_id();
    
    
    $settings = array('name'        => 'ezlogo',
          'title'       => 'Ez Logo',
          'description' => 'Add Logo\'\' url',
          'optionscode' => 'yesno',
          'value'       => 'yes',
          'disporder'   => '100',
          'gid'         => $group['gid'],
           );

            $db->insert_query('settings', $settings);
        
        
        $settings1 = array('name'        => 'ezlogo_url',
         'title'       => 'Url',
         'description' => 'Inserte logo\'\' Inseret logo url',
         'optionscode' => 'text',
         'value'       => 'http://',
         'disporder'   => '100',
         'gid'         => $group['gid'],
          );

            $db->insert_query('settings', $settings1);
}
function ezlogo_deactivate(){
    global $db;
    $db->delete_query("settings", "name='ezlogo'");
    $db->delete_query("settings", "name='ezlogo_url'");
    $db->delete_query("settinggroups", "name='ezlogo'");
}

function ezlogo_insert(){
global $mybb, $templates, $theme;
if(intval($mybb->settings['ezlogo']) == "1"){
$theme['logo'] = $mybb->settings['ezlogo_url'];
} 
} 


?>
One issue, logo isnt getting replaced xD. What happens if the image is a .png and .gif?
It should work with either type.
Hmm didnt work, let me try again.
Bump.
It doesnt work, also this is a bump.

I enter the url but nothing.

<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook('global_start','ezlogo_insert');

function ezlogo_info()
{
    
    return array(
        "name"            => "Ez Logo",
        "description"    => "Adds a logo super easy!",
        "website"        => "http://mods.mybb.com",
        "author"        => "Blake",
        "authorsite"    => "http://mcmines.com",
        "version"        => "1.2",
        "compatibility" => "16*"
    );
}



function ezlogo_activate()
{
    global $db;
    require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
    $query = $db->simple_select("settinggroups", "COUNT(*) as rows");
    $rows = $db->fetch_field($query, "rows");

    $insertarray = array(
        'gid' => 'NULL', 
        'name' => 'ezlogo', 
        'title' => 'Ez Logo', 
        'description' => 'Adds a Logo with ease!', 
        'disporder' => $rows+1, 
        'isdefault' => 'no'
    );
    $db->insert_query("settinggroups", $insertarray);
    $group['gid'] = $db->insert_id();
    
    
    $settings = array('name'        => 'ezlogo',
          'title'       => 'Ez Logo',
          'description' => 'Is the plugin on or no?',
          'optionscode' => 'yesno',
          'value'       => 'yes',
          'disporder'   => '100',
          'gid'         => $group['gid'],
           );

            $db->insert_query('settings', $settings);
        
        
        $settings1 = array('name'        => 'ezlogo_url',
         'title'       => 'Url',
         'description' => 'Insert logo url',
         'optionscode' => 'text',
         'value'       => 'http://',
         'disporder'   => '100',
         'gid'         => $group['gid'],
          );

            $db->insert_query('settings', $settings1);
}
function ezlogo_deactivate(){
    global $db;
    $db->delete_query("settings", "name='ezlogo'");
    $db->delete_query("settings", "name='ezlogo_url'");
    $db->delete_query("settinggroups", "name='ezlogo'");
}

function ezlogo_insert(){
global $mybb, $templates, $theme;
if(intval($mybb->settings['ezlogo']) == "1"){
$theme['logo'] = $mybb->settings['ezlogo_url'];
} 
} 


?>