POST TIME:2021-05-20 00:49
dede投票模塊在首頁的調用
本文介紹dedecms投票模塊在首頁的調用方法,大家可以參考寫出更符合自己需要的效果。
先來看dedecms默認模板里的投票模塊在首頁調用的代碼:
<!–投票調查–>
<div class=”rlist margintop”>
<form name=’voteform’ method=’post’ action='{dede:field name=’phpurl’/}/vote.php’ target=’_blank’>
<input type=’hidden’ name=’dopost’ value=’send’>
<input type=’hidden’ name=’aid’ value=’1′>
<input type=’hidden’ name=’ismore’ value=’0′>
<div class=”title”>你是從哪兒得知本站的?</div>
<div class=”rbox vote”>
<span><input name=”voteitem” type=”radio” value=”1″ />朋友介紹</span>
<span><input name=”voteitem” type=”radio” value=”2″ />門戶網站的搜索引擎</span>
<span><input name=”voteitem” type=”radio” value=”3″ />Google或百度搜索 </span>
<span><input name=”voteitem” type=”radio” value=”4″ />別的網站上的鏈接 </span>
<span><input name=”voteitem” type=”radio” value=”5″ />其它途徑 </span>
<div class=”votesubmit”>
<input type=”submit” value=”投票” class=”submit” />
<a href=”{dede:field name=’phpurl’/}/vote.php?dopost=view&aid=1″>查看結果</a>
</div>
</div>
</form>
</div>
<!–投票調查結束–>
代碼中從form開始即是表單區域,一般根據網站需要,需要修改的是選項(radio)里的 value屬性,這個value屬性是你在后臺添加投票選項時對應的ID。
方法二
后臺里,點擊希望在主頁調用的投票的“查看代碼”,如下圖:
將代碼替換/templets/default/index.htm文件里的如下代碼:
<div class=”vote mt1″>
<dl class=”tbox”>
<dt><strong>投票調查</strong></dt><form name=’voteform’ method=’post’ action=’/plus/vote.php’ target=’_blank’>
<input type=’hidden’ name=’dopost’ value=’send’ />
<input type=’hidden’ name=’aid’ value=’1′ />
<input type=’hidden’ name=’ismore’ value=’0′ />
<dd> <strong>你是從哪兒得知本站的?</strong>
<div class=”fb”>
<input type=”radio” name=’voteitem’ value=’1′ />
朋友介紹</div>
<div class=”fb”>
<input type=”radio” name=’voteitem’ value=’2′ />
門戶網站的搜索引擎</div>
<div class=”fb”>
<input type=”radio” name=’voteitem’ value=’3′ />
google或百度引擎</div>
<div class=”fb”>
<input type=”radio” name=’voteitem’ value=’4′ />
別的網站上的鏈接</div>
<div class=”fb”>
<input type=”radio” name=’voteitem’ value=’5′ />
其他途徑</div>
<div class=”submit”>
<button type=”submit” class=”btn-1″>投票</button>
<a href=”plus/vote.php?dopost=view&aid=1″>查看結果</a></div>
</dd>
</form>
</dl>
</div>
此方法雖簡便點,但效果不太美觀
PS:又鼓搗了一會,發現可將如上代碼替換成:
<!– 以下為投票模塊 –>
<div class=”vote mt1″>
<dl class=”tbox”>
<dt><strong>投票調查</strong></dt>
<form name=’voteform’ method=’post’ action=’/plus/vote.php’ target=’_blank’>
<input type=’hidden’ name=’dopost’ value=’send’ />
<input type=’hidden’ name=’aid’ value=’1′ />
<input type=’hidden’ name=’ismore’ value=’0′ />
<dd>
<div class=”fb”>
<!– 以下粘貼投票代碼 –>
{dede:vote id=’2′}
{/dede:vote}
<br />
<!– 以上粘貼投票代碼 –>
</div>
</dd>
</form>
</dl>
</div><!– 以上為投票模塊 –>
這樣,每次只要更改我用特殊字體標出的投票ID(見后臺)“2”,便可實現首頁投票模塊更新。加個</br>換行符是為了勻稱。
更新完后記得要在后臺更新主頁HTML