di Alfredo Cosco
Download How To
Anche il blocco per il LOG IN in Flatnuke può essere ottimizzato in termini di spazio ed essere messo in qualunque punto del tema.
Analogamente a quanto già fatto per il blocco SEARCH possiamo procedere così...
1) creiamo un file php vuoto in include/phpfunctions/ con un nome a piacere, ad esempio myfunctions.php (nel caso avese seguito il tutorial per il blocco search non c'è bisogno).
2) copiamo questa funzione nel file:
function small_login_panel()
{
// Security checks
$req = getparam("REQUEST_URI", PAR_SERVER, SAN_FLAT);
if(strstr($req,"myforum="))
die(_NONPUOI);
// user is not logged
if(is_guest()) {
?>
<form action="index.php?mod=none_Login" method="post">
<input type="hidden" name="action" value="login" />
<input type="hidden" name="from" value="home" />
<!--label for="username"><?= _NOMEUTENTE ?>:</label-->
<input alt="username" name="nome" size="10" id="username" style="color:grey" value="Username"
onfocus="if(this.value=='Username'){this.value='';}" onblur="if(this.value==''){this.value='Username';}" />
<!--label for="password"><?= _PASSWORD ?>:</label-->
<input alt="password di accesso" name="logpassword" type="password" size="10" id="password" style="color:grey;"
value="********" onclick="javascript:this.value='';" /><?
// remember login checkbox
global $remember_login;
if($remember_login==1) {
echo "<label for="rememberlogin">Ricorda</label>";
echo "<input type="checkbox" alt="remember_login" name="rememberlogin" id="rememberlogin" />";
} else echo "";
// login button
?><input type="submit" value="<?= _LOGIN ?>" />
<?
// link to register
global $reguser;
if ($reguser=="1" or $reguser=="2"){
?>
<a href="index.php?mod=none_Login&action=visreg" title="<?=_REGORA?>"><b><?=_REGORA?></b></a>
<a href="index.php?mod=none_Login&action=passwordlost" title="<?=_NEWPWDSTRING?>">
<b><?=_NEWPWDSTRING?></b></a><?
}
?></form><?
}
// user is logged
elseif(is_user() OR is_admin()) {
$userdata = array();
$userdata = load_user_profile(get_username());
// print user name
$username = get_username();
print _BENVENUTO." <b><a href='index.php?mod=none_Login&action=viewprofile&user=$username' title=""._VIEW_USERPROFILE."">$username</a></b>!";
print "<a href='index.php?mod=none_Login&action=viewprofile&user=$username' title=""._VIEW_USERPROFILE."">";
print "</a>";
// administrator panel
if(is_admin()) {
?>
» <a href="index.php?mod=none_Admin" title="<? echo _MANAGEFLATNUKE; ?>"><?= _MANAGEFLATNUKE ?></a>
» <a href="index.php?mod=none_Admin&op=fnccnews" title="<? echo _ADDNEWS; ?>"><?= _ADDNEWS ?></a>
<?
}
// logout
echo "<a href='index.php?mod=none_Login&action=logout&from=home' title=""._LOGOUT.""><b>"._LOGOUT."</b></a>";
}
else echo "Cookie mismatch, please <a href='index.php?mod=none_Login&action=logout&from=home'>delete your cookies!</a>";
}
/**End**/
3) aggiungiamo un ID per il form nel nostro style.css del tema per formattare il tutto
#loginpan
{
}
#loginpan input
{
}
.....
4) aggiungiamo la chiamata alla funzione nel file structure.php del tema dove più ci aggrada
<div id="tema" >
<!-- TOP -->
<div id="topmenu">
<div id="topleft">
<h1><a href="#">Il mio sito</a></h1>
<div id="loginpan"><? small_login_panel();?></div>
</div>
<div id="topright"></div>
</div>
....
5) formattare a piacere e servire ben caldo