在BizIdea版本當中,我們在后臺對某個節點設置時,啟用了對評論使用驗證碼功能,但前臺發表評論時卻沒有出現驗證碼,這個不是BUG問題,系統功能其實已經存在,只不過沒有通過標簽調用實現而已,下面我們來一步步實現它。
---------------(以下以文章類模型并且是默認的系統代碼為例進行講解)
第一步:通過分析內容頁模板,發現調用評論的代碼為
//評論相關代碼
function commentinit()
{
var x = new AjaxRequest('XML','commentform');
x.labelname = "內容評論PK標簽"; // 紅色代碼表示調用了一個標簽,名稱為“內容評論PK標簽”
x.para = ['itemId=@RequestInt_id']; //紅色代碼表示這個標簽的一個參數,這個參數自動接受當前文章ID值
............. 其下代碼省略,因為關鍵代碼就是上面兩處
第二步:標簽管理里我們打開“內容評論PK標簽”,可以看到這個標簽有個參數正是“itemId”,我們直接到最后一步,看看它有沒有調用進一步的標簽,我們可以很容易的看到調用的標簽代碼
<div class="article_PK" id="indiv">
{PE.Label id="發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>" /} //這個就是嵌套調用的標簽
</div>
第三步:標簽管理里我們打開“發表評論用戶信息”標簽,同樣可以看到這個標簽有個“itemId”參數,我們繼續進行到最后一步,發現有三處地方調用了同一個標簽,調用標簽代碼如下
<xsl:when test="pe:EnableTouristsComment(NewDataSet/Table/NodeID)='true'">{PE.Label id="顯示發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>" /}</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="pe:IsLogined()='true'">{PE.Label id="顯示發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>"/}</xsl:when>
<xsl:otherwise>
<font style="color:red">該信息所屬欄目不允許游客發表評論!</font>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="pe:UserPurview('commentcheck',NewDataSet/Table/NodeID)='true'">{PE.Label id="顯示發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>"/}</xsl:when>
<xsl:otherwise>
不能顯示出驗證碼的問題在這個標簽的調用里就體現出第一步了,為什么這么說,我們先來看看啟用驗證碼的功能代碼是什么:
<xsl:if test="pe:GetNodeEnableValidCode($nodeid)='true'">
<img id="VcodeLogOn" title="看不清楚,筆換一個" onclick="refreshValidateCodeImage(this);" src="{pe:InstallDir()}Controls/validateCodeImage.aspx" align="absmiddle" style="border:none;cursor:pointer;" /> <xsl:text disable-output-escaping="yes"> </xsl:text>
<input name="TxtValidCode" type="text" maxlength="6" value="" id="TxtValidCode" class="input1" size="12" onfocus="this.select();" /> <xsl:text disable-output-escaping="yes"> </xsl:text>
</xsl:if>
--------關鍵功能代碼是紅色標識出的,其中它要接受一個傳遞值(藍色代碼標識的),這個參數就是當前文章所屬節點的ID,而在對“顯示發表評論用戶信息”標簽調用時,卻缺少了這個參數的傳遞,所以我們要補充一下,補充代碼如下,“nodeid”這個就是新設置的參數:
{PE.Label id="顯示發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>" nodeid="<xsl:value-of select="NewDataSet/Table/NodeID"/>" /}
第四步:標簽里我們打開“顯示發表評論用戶信息”標簽,在這里我們就要開始著手補充上面所說的參數,如圖所示
添加后,點下一步,插入紅色代碼:
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pe="labelproc" exclude-result-prefixes="pe">
<xsl:output method="html" />
<xsl:param name="nodeid"/> //先這義這個參數,這樣才能在代碼里引用這個參數
<xsl:template match="/">
-----------------------
在合適的地方加上前面所說的調用驗證碼功能的代碼,比如我們這里是加在這里:
<div class="PK_indiv_r">
<textarea wrap="off" id="content">
</textarea>
<br />
<xsl:if test="pe:GetNodeEnableValidCode($nodeid)='true'">驗證碼:
<img id="VcodeLogOn" title="看不清楚,換一個" onclick="refreshValidateCodeImage(this);" src="{pe:InstallDir()}Controls/validateCodeImage.aspx" align="absmiddle" style="border:none;cursor:pointer;" /> <xsl:text disable-output-escaping="yes"> </xsl:text>
<input name="TxtValidCode" type="text" maxlength="6" value="" id="TxtValidCode" class="input1" size="12" onfocus="this.select();" /> <xsl:text disable-output-escaping="yes"> </xsl:text>
</xsl:if>
<input type="submit" name="BtnLogin" value="發表評論" onClick="addcomment()" />
<xsl:if test="pe:IsLogined()='true'">
<input type="checkbox" id="open" checked="true" onClick="setprivate()" />公開
</xsl:if>
然后,還需對“發表評論用戶信息”標簽中有關對“顯示發表評論用戶信息”標簽的調用都加上相應的參數,如下:
{PE.Label id="顯示發表評論用戶信息" itemId="<xsl:value-of select="$itemId"/>" nodeid="<xsl:value-of select="NewDataSet/TabledeID"/>" /}
添加好后,我們保存標簽,現在我們可以看看前臺效果:
附:如果改不過來的,請把“評論標簽”下載覆蓋到你站中的“/Template/商城模板方案/標簽庫/評論類”目錄下,即可。
“評論標簽”地址:http://help.powereasy.net/help/UploadFiles_4256/200904/2009040816151010.rar
新聞熱點
疑難解答
圖片精選