POST TIME:2020-03-28 16:55
我想有很多朋友想嘗試將留言本的標(biāo)題調(diào)用首頁,而自成首頁的一個欄目,下面是我從網(wǎng)上學(xué)到的調(diào)用方法,現(xiàn)發(fā)出來,供大家研究參考。
步驟:
1、用PHPMYADMIN登陸您的數(shù)據(jù)庫,找到DEDE數(shù)據(jù)庫中的"guestbook"表,增加一個"guesttitle"字段,設(shè)為"varchar",字段大小自定。
>>>如果不想JS調(diào)用達(dá)到實時更新的目的,可以跳過步驟2和6,完成步驟3、4、5后直接使用loop循環(huán)標(biāo)記:
{dede:loop table='dede_guestbook' sort='dtime' row='10' if='ischeck=1'}
<a href="[field:phpurl/]/guestbook/index.php" >[field:guesttitle function="cn_substr('@me',30)"/]</a><br>
{/dede:loop}
2、在/plus/guestbook/下新建一個js.php文件,js.php內(nèi)容如下:
<?php
require_once(dirname(__FILE__)."/config.php");
require_once(dirname(__FILE__)."/../../include/pub_datalist_dm.php");
setcookie("GUEST_BOOK_MOVE",GetCurUrl(),time()+3600,"/");
function GetIsCheck($ischeck,$id)
{
if($ischeck==0) return "<br><a href='edit.php?job=check&ID=$id' style='color:red'>[審核]</a>";
else return "";
}
if($userrank>0) $sql = "select * from dede_guestbook order by ID desc";
else $sql = "select * from dede_guestbook where ischeck=1 order by ID desc";
$dlist = new DataList();
$dlist->Init();
$dlist->pageSize =10;
$dlist->SetParameter("gotopagerank",$gotopagerank);
$dlist->SetSource($sql);
$mylist = $dlist->GetDataList();
while($row = $mylist->GetArray('dm'))
{
$xingming=$row['uname'];
$neirong=strip_tags($row['guesttitle']);
$neirong=str_replace(" ","",$neirong);
$neirong=cn_substr($neirong,25);
$neirong=str_replace("
","",$neirong);
$neirong=rawurldecode($neirong);
$link=$row['ID'];
echo "document.write(&;- <a href='./plus/guestbook/index.php#$link' target='_blank'>$neirong</A><br>&;);";
}
$dlist->Close();
?>
3、在 empletsplusguestbook.htm文件中加上命名錨記
找到
<?php
$mylist = $dlist->GetDataList();
while($row = $mylist->GetArray('dm'))
{
?>
在后邊加入
CODE:
<a name="<?echo $row['ID']?>"></a>
4、在/templets/plus/guestbook.htm中加入讀取留言本標(biāo)題的代碼"<?php echo $row['guesttitle']?>"到您想要的位置。