Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
2011-05-15, 06:38 AM
(This post was last modified: 2011-05-15, 06:54 AM by blake.)
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. 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!
Posts: 13,283
Threads: 159
Joined: Oct 2010
Reputation:
1,291
2011-05-15, 06:54 AM
(This post was last modified: 2011-05-15, 06:55 AM by Yaldaram.)
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.
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
(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 slowly but surly getting there with this plugin making.
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!
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
Bump, can ya answer my last question please?
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!
Posts: 13,283
Threads: 159
Joined: Oct 2010
Reputation:
1,291
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'];
}
}
?>
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
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!
Posts: 1,637
Threads: 10
Joined: Dec 2009
Reputation:
91
It should work with either type.
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
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!
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
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!
Posts: 1,179
Threads: 255
Joined: Dec 2009
Reputation:
13
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!
|