Replace forum logo?
#1
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????");
} 
} 
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#2
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.
Reply
#3
(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
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#4
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";
} 
} 


?>
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#5
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'];
} 
} 


?>
Reply
#6
One issue, logo isnt getting replaced xD. What happens if the image is a .png and .gif?
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#7
It should work with either type.
Reply
#8
Hmm didnt work, let me try again.
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#9
Bump.
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply
#10
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'];
} 
} 


?>
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.
My mods Clicky!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)