問題:如何制作涉及數(shù)據(jù)庫(kù)多表操作的標(biāo)簽,比如想在首頁(yè)顯示一最新推薦圖片文章。
解決方法:按函數(shù)標(biāo)簽說(shuō)明(http://tech.powereasy.net/help/PowerEasy2006/1148.html),制件標(biāo)簽如下:
查詢語(yǔ)句:
select top 1 * from PE_Article where Elite={$PE_True} order by ArticleID DESC
標(biāo)簽內(nèi)容:
{Loop}{Infobegin} <table height=50 cellSpacing=0 cellPadding=0 width=530 align=center border=0>
<tr>
<td><A href="{$InstallDir}{$Field(0,GetUrl,Article,1)}" target=_blank><IMG height=50 src="{$InstallDir}Article/UploadFiles/{$Field(21,Text,0,0,0)}" width=530 border=0></A></td>
</tr>
</table>
{Infoend}{/Loop}
通常網(wǎng)站中有幾個(gè)文章類型的頻道,而最新的文章又不確定在某個(gè)文章類型的頻道下。那么把上述標(biāo)簽添加到首頁(yè),就可能存在圖片不顯示的問題。
比如首頁(yè)顯示的圖片應(yīng)該是http://www.***.net/zixun/UploadFiles_7381/200809/2008092616374776.gif
結(jié)果按上述標(biāo)簽形成的圖片路徑:http://www.***.net/Article/UploadFiles/200809/2008092616374776.gif
顯然標(biāo)簽中“{$InstallDir}Article/UploadFiles/”是把圖片都放在默認(rèn)的文章頻道中,寫法是不正確的。
那么,我們?nèi)绾伟?ldquo;Article”替換為圖片實(shí)際所在的頻道目錄、“uploadfiles”替換成圖片實(shí)際所在的頻道的上傳文件目錄,顯示標(biāo)簽的查詢語(yǔ)句不對(duì),沒有調(diào)出具體的頻道目錄和頻道上傳目錄。修改代碼如下:
查詢語(yǔ)句:
select top 1 PE_Article.ArticleID,PE_Article.ChannelID,PE_Article.Title,PE_Article.DefaultPicUrl,PE_Channel.ChannelDir,PE_Channel.UploadDir from PE_Article inner join PE_Channel on PE_Article.ChannelID = PE_Channel.ChannelID where PE_Article.Elite={$PE_True} order by ArticleID DESC
標(biāo)簽顯示代碼:
{Loop}{Infobegin}
<table height=50 cellSpacing=0 cellPadding=0 width=530 align=center border=0>
<tr>
<td><A href="{$InstallDir}{$Field(0,GetUrl,Article,1)}" target=_blank><IMG height=50 src="{$InstallDir}{$Field(4,Text,0,0,0)}/{$Field(5,Text,0,0,0)}/{$Field(3,Text,0,0,0)}" width=530 border=0></A></td>
</tr>
</table>
{Infoend}{/Loop}
當(dāng)然,還可以通過(guò)修改顯示代碼,在前臺(tái)顯示圖片文章標(biāo)題、顯示多個(gè)圖片等等。
新聞熱點(diǎn)
疑難解答
圖片精選