织梦首页调用系统投票模块方法


dede投票模块在首页的调用

今天织梦58小编介绍dedecms投票模块在首页的调用方法,大家可以参考写出更符合自己需要的效果。

先来看dedecms默认模板里的投票模块在首页调用的代码:

01 <!--投票调查-->
02  <div class="rlist margintop">
03       <form name='voteform' method='post' action='{dede:field name='phpurl'/}/vote.php' target='_blank'>
04   <input type='hidden' name='dopost' value='send'>
05   <input type='hidden' name='aid' value='1'>
06   <input type='hidden' name='ismore' value='0'>
07   <div class="title">你是从哪儿得知本站的?</div>
08   <div class="rbox vote">
09    <span><input name="voteitem" type="radio" value="1" />朋友介绍</span>
10    <span><input name="voteitem" type="radio" value="2" />门户网站的搜索引擎</span>
11    <span><input name="voteitem" type="radio" value="3" />Google或百度搜索 </span>
12    <span><input name="voteitem" type="radio" value="4" />别的网站上的链接 </span>
13    <span><input name="voteitem" type="radio" value="5" />其它途径 </span>
14    <div class="votesubmit">
15     <input type="submit" value="投票" class="submit" />
16     <a href="{dede:field name='phpurl'/}/vote.php?dopost=view&aid=1">查看结果</a>
17    </div>
18   </div>
19       </form>
20  </div>
21  <!--投票调查结束-->

代码中从form开始即是表单区域,一般根据网站需要,需要修改的是选项(radio)里的 value属性,这个value属性是你在后台添加投票选项时对应的ID。

方法二

后台里,点击希望在主页调用的投票的“查看代码”,如下图:

将代码替换/templets/default/index.htm文件里的如下代码:

01    <div class="vote mt1">
02       <dl class="tbox">
03         <dt><strong>投票调查</strong></dt>
04  
05 <form name='voteform' method='post' action='/plus/vote.php' target='_blank'>
06 <input type='hidden' name='dopost' value='send' />
07 <input type='hidden' name='aid' value='1' />
08 <input type='hidden' name='ismore' value='0' />
09         <dd> <strong>你是从哪儿得知本站的?</strong>
10             <div class="fb">
11               <input type="radio" name='voteitem' value='1' />
12               朋友介绍</div>
13           <div class="fb">
14              <input type="radio" name='voteitem' value='2' />
15             门户网站的搜索引擎</div>
16           <div class="fb">
17             <input type="radio" name='voteitem' value='3' />
18             google或百度引擎</div>
19           <div class="fb">
20             <input type="radio" name='voteitem' value='4' />
21             别的网站上的链接</div>
22           <div class="fb">
23              <input type="radio" name='voteitem' value='5' />
24             其他途径</div>
25           <div class="submit">
26            <button type="submit" class="btn-1">投票</button>
27             <a href="plus/vote.php?dopost=view&aid=1">查看结果</a></div>
28         </dd>
29 </form>
30       </dl>
31     </div>

此方法虽简便点,但效果不太美观

PS:又鼓捣了一会,发现可将如上代码替换成:

01    <!-- 以下为投票模块 -->
02     <div class="vote mt1">
03       <dl class="tbox">
04         <dt><strong>投票调查</strong></dt>
05           <form name='voteform' method='post' action='/plus/vote.php'target='_blank'>
06            <input type='hidden' name='dopost' value='send' />
07            <input type='hidden' name='aid' value='1' />
08            <input type='hidden' name='ismore' value='0' />
09             <dd>
10               <div class="fb">
11 <!-- 以下粘贴投票代码 -->
12                {dede:vote id='2'}
13                {/dede:vote}
14                <br />
15 <!-- 以上粘贴投票代码 -->
16               </div>
17             </dd>
18           </form>
19       </dl>
20     </div>
21  
22     <!-- 以上为投票模块 -->

这样,每次只要更改我用特殊字体标出的投票ID(见后台)“2”,便可实现首页投票模块更新。加个</br>换行符是为了匀称。

更新完后记得要在后台更新主页HTML

效果如下: