Войти

Показать полную графическую версию : шаблон


slaine
24-11-2005, 15:54
hail.
Вот есть такой скрипт шаблона.
page.inc.


class page
{

var $title;
var $keywords;
var $content;

var $links = array( "index" => "index.php",
"contacts" => "contacts.php",
"download" => "download.php"
);

function settitle($newtitle){
$this->title = $newtitle;
}

function setkeywords($newkeywords){
$this->keywords = $newkeywords;
}

function setcontent($newcontent){
$this->content = $newcontent;
}

function Display(){
echo "<html><head>";
echo "<title> $this->title </title>";
echo "<META content='text/html; charset=windows-1251' http-equiv=Content-Type>";
echo $this->keywords;
echo "<style>
A:link {color: #666666; text-decoration: underline; font-family: arial, helvetiva; font-size: 11px; font-weight: normal};
A:visited {color: #666666; text-decoration: underline; font-family: arial, helvetiva; font-size: 11px; font-weight: normal};
A:hover {color: orangered; text-decoration: none; font-family: arial, helvetiva; font-size: 11px; font-weight: normal};
</style>";
echo "</head><body>";
$this -> DisplayMenu($this->links);
echo $this->content;
echo "</body></html>";
}


function DisplayMenu($links){
echo "<table width = 100% bgcolor=#ffffff cellpadding = 4 cellspacing = 0>
<colgroup align=center>
<tr>";

$width = 100/count($links);

foreach ($links as $name => $url){
$this->DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));
}
echo " </tr>
</table>";
}

function IsURLCurrentPage($url){
if(strpos( $_SERVER['PHP_SELF'], $url ) == false){
return false;
} else {
return true;
}
}

function DisplayButton($width, $name, $url, $active = true){
if ($active)
{
echo "<td width = ".$width."%>
<a href = ".$url."><span>".$name."</span></a></td>";
} else {
echo "<td width = ".$width."%>
<span><B>".$name."</B></span></td>";
}
}

}



В свою очередь index.php:



require ("page.inc");

$homepage = new Page();

$homepage -> settitle("news");

$homepage -> setkeywords("<META content='' name=keywords>");

$homepage -> setcontent("<CENTER><H1>НОВОСТИ</H1><CENTER>");

$homepage -> Display();
Скажите, как можно к этому срипту(page.inc) прикрутить какой-нибудь скрипт, например: guest book?

vadimiron
24-11-2005, 19:47
Любой guest book генерирует по сути определённый контент, то есть пользуемся $homepage -> setcontent, чтобы вывести то, что сгенерировал скрипт гостевухи

slaine
09-12-2005, 21:25
vadimiron объясните пожалуста, а как вывести такой контент, я выделило его жирным:

<?
if (file_exists("text2.dat")){
$f = file("text2.dat");
$f = array_reverse($f);
$count = count($f);


for ($i = 0; $i < $count; $i ++){
$line = explode("\t", $f[$i]);

echo "<tr><td width=300 bgColor=beige style='word-wrap: break-word'><font color=maroon style='background: yellow; width: 300px'><B>".$line[0]."</font></B><BR>
".ass($line[1])."<BR>";
if (isset($line[2])){
echo "<font color=red>".ass($line[2])."</font><BR>";
}
echo "<a href=aaa2.php?id=".$i.">ansewer</a>&nbsp;&nbsp;&nbsp;
<a href=aaa3.php?id=".$i.">delete</a>&nbsp;&nbsp;&nbsp;
<a href=aaa4.php?id=".$i.">edit</a></td></tr>"; }

vadimiron
09-12-2005, 23:03
$text.= "<tr><td width=300 bgColor=beige style='word-wrap: break-word'><font color=maroon style='background: yellow; width: 300px'><B>".$line[0]."</font></B><BR>
".ass($line[1])."<BR>";
if (isset($line[2])){
$text.= "<font color=red>".ass($line[2])."</font><BR>";
}
$text.= "<a href=aaa2.php?id=".$i.">ansewer</a>
<a href=aaa3.php?id=".$i.">delete</a>
<a href=aaa4.php?id=".$i.">edit</a></td></tr>";

а потом
$homepage -> setcontent($text)

slaine
10-12-2005, 00:19
блин...., спасибо vadimiron!

vadimiron
10-12-2005, 01:06
slaine
Всегда рад :)




© OSzone.net 2001-2012