2010-11-07, 06:54 PM
Hi guys, i created a plugin, i upload it in inc/plugins, I go to pca and active but does not give me no errors. I go into the index (which I had set as a hook), but you can't see what I did ... What is wrong? I post the code I did:
As you see I added two hooks, the index.php (start) and portal.php (start) and as a function I put "avvisospiti"
$plugins->add_hook('index_start', 'avvisospiti', './index.php');
$plugins->add_hook('portal_start', 'avvisospiti', './portal.php');
and then I wrote the function "avvisospiti"
where in the code invokes a language:
As you can see it should be all right, but I do not understand why they can not see anything in index.php and portal.php
P.S. I also tried to add priority to the hock (index Priority 1 and Priority 2 portal), but nothing ...
Can you help me???
<?php
if(!defined("IN_MYBB"))
die("This file cannot be accessed directly.");
$plugins->add_hook('index_start', 'avvisospiti', './index.php');
$plugins->add_hook('portal_start', 'avvisospiti', './portal.php');
function avvisospiti_info() {
return array(
'name' => 'Avviso Ospiti / Guest warn',
'description' => 'Crea un avviso elegante a tutti gli ospiti del vostro forum. Make a elegant warn for all guest of your forum.',
'website' => 'http://www.cionfs.it/',
'author' => 'Clear',
'authorsite' => 'http://www.downloadsafe.altervista.org',
'version' => '1',
);
}
function avvisospiti_lang()
{
global $lang;
$lang->load('avvisospiti',false,true);
$l['avvisospiti_messaggio']='Ciao Ospite, se leggi questo messaggio significa che non sei registrato. <a href="member.php?action=register">Clicca qui</a> per effettuare la registrazione in pochi semplici passaggi e potrai usufruire di tutte le funzioni del nostro Forum . Ti ricordiamo che sono vietati nick volgari o privi di senso (no numeri o lettere a caso) e di presentarti nella sezione apposita per farti conoscere alla nostra community!';
foreach($l as $key=>$val)
{
if(!$lang->$key)
{
$lang->$key=$val;
}
}
}
function avvisospiti()
{
global $mybb;
if($mybb->user['usergroup']==1)
{
global $theme,$lang,$avvisospiti;
avvisospiti_lang();
$avvisospiti='<head><style>#avviso { background: #000; color: #fff; font-size: 10px; border: 0px solid #94c2e8; padding: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; filter:alpha(opacity=88); -moz-opacity:.88; opacity:.88; -moz-box-shadow:5px 5px 5px #191919; -webkit-box-shadow:5px 5px 5px #191919; box-shadow:5px 5px 5px #191919; } #avviso a:link { color: #fff; text-decoration: none; } #avviso a:visited { color: #fff; text-decoration: none; } #avviso a:hover, #avviiso a:active { color: #fff; text-decoration: underline; } .avviso_fixed { height: auto; position: fixed; top: 50%; right: 0%; width: 280px; } </style></head> <div class="avviso_fixed"><div id="avviso">'.$lang->avvisospiti_messaggio.'</div></div>';
}
}
?>
As you see I added two hooks, the index.php (start) and portal.php (start) and as a function I put "avvisospiti"
$plugins->add_hook('index_start', 'avvisospiti', './index.php');
$plugins->add_hook('portal_start', 'avvisospiti', './portal.php');
and then I wrote the function "avvisospiti"
function avvisospiti()
{
global $mybb;
if($mybb->user['usergroup']==1)
{
global $theme,$lang,$avvisospiti;
avvisospiti_lang();
$avvisospiti='<head><style>#avviso { background: #000; color: #fff; font-size: 10px; border: 0px solid #94c2e8; padding: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; filter:alpha(opacity=88); -moz-opacity:.88; opacity:.88; -moz-box-shadow:5px 5px 5px #191919; -webkit-box-shadow:5px 5px 5px #191919; box-shadow:5px 5px 5px #191919; } #avviso a:link { color: #fff; text-decoration: none; } #avviso a:visited { color: #fff; text-decoration: none; } #avviso a:hover, #avviiso a:active { color: #fff; text-decoration: underline; } .avviso_fixed { height: auto; position: fixed; top: 50%; right: 0%; width: 280px; } </style></head> <div class="avviso_fixed"><div id="avviso">'.$lang->avvisospiti_messaggio.'</div></div>';
}
}
where in the code invokes a language:
function avvisospiti_lang()
{
global $lang;
$lang->load('avvisospiti',false,true);
$l['avvisospiti_messaggio']='Ciao Ospite, se leggi questo messaggio significa che non sei registrato. <a href="member.php?action=register">Clicca qui</a> per effettuare la registrazione in pochi semplici passaggi e potrai usufruire di tutte le funzioni del nostro Forum . Ti ricordiamo che sono vietati nick volgari o privi di senso (no numeri o lettere a caso) e di presentarti nella sezione apposita per farti conoscere alla nostra community!';
foreach($l as $key=>$val)
{
if(!$lang->$key)
{
$lang->$key=$val;
}
}
}
As you can see it should be all right, but I do not understand why they can not see anything in index.php and portal.php
P.S. I also tried to add priority to the hock (index Priority 1 and Priority 2 portal), but nothing ...
Can you help me???