請教下拉框里填文章標題,選擇文章標題點擊跳轉到文章頁怎么寫呢
<form id="competitionform" name="competitionform" action="/index.php" method="GET">
<input type="hidden" name="s" value="api">
<input type="hidden" name="c" value="api">
<select name="competition" id="competition" class="makeMeFancy" onchange="this.form.submit();">
{module module=news catid=18}
<option value="4">{$t.title}</option>
{/module}
</select>
</form>
官方提醒:使用module內容循環(huán)標簽的生成工具,填寫參數(shù)就可以生成相關的代碼,每個參數(shù)后面都有用法解釋
<form id="competitionform" name="competitionform" action="/index.php" method="GET"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="tiao"> <select name="competition" id="competition" class="makeMeFancy" onchange="this.form.submit();"> {module module=news catid=18} <option value="4">{$t.title}</option> {/module} </select> </form>再新建文件dayrui/app/news/Controllers/Tiao.php,代碼如下
<?php namespace Phpcmf\Controllers; class Tiao extends \Phpcmf\Home\Module { public function index() { $this->_module_init(); $data = $this->content_model->get_data((int)\Phpcmf\Service::L('Input')->get('id')); if ($data) { \Phpcmf\Service::L('Router')->is_redirect_url(dr_url_prefix($data['url'], $this->module['dirname'])); } else { exit("文章不存在"); } } }回復@齊云電商我上面寫的沒問題嗎,option里的value值不需要改嗎,就是在核心文件做個擴展嗎
<form id="competitionform" name="competitionform" action="/index.php" method="GET"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="tiao"> <select name="id" id="competition" class="makeMeFancy" onchange="this.form.submit();"> {module module=news catid=18} <option value="4">{$t.title}</option> {/module} </select> </form>表單改一下selet的name
回復@齊云電商
http://www.stw.cn/index.php?s=api&c=api&id=4
顯示這個頁面搜索不到
回復@齊云電商
http://www.stw.cn/index.php?s=api&c=api&id=4
顯示這個頁面搜索不到
回復@master888
404錯誤
<form id="competitionform" name="competitionform" action="/index.php" method="GET"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="tiao"> <select name="id" id="competition" class="makeMeFancy" onchange="this.form.submit();"> {module module=news catid=18} <option value="{$t.id}">{$t.title}</option> {/module} </select> </form>改下value值,擴展控制器啊,不影響程序對比和升級
回復@齊云電商id獲取到了,但是還是404呢
http://www.stw.cn/index.php?s=news&c=tiao&id=4
回復@齊云電商
http://www.stw.cn/index.php?s=api&c=api&id=5
是這個形式的url
http://www.stw.cn/index.php?s=news&c=tiao&id=4
這樣訪問才對,我擴展控制器是寫的這種url
<form id="competitionform22" name="competitionform" action="/index.php" method="GET"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="tiao"> <select name="id" class="makeMeFancy" onchange="document.getElementById("competitionform22").submit(); "> {module module=news catid=18} <option value="{$t.id}">{$t.title}</option> {/module} </select> </form><select name="id" class="makeMeFancy" onchange="document.getElementById('competitionform22').submit(); ">回復@齊云電商
應該是單引號吧,兩個雙引號肯定是錯的
回復@往事別了
按你這樣還是跳轉到我上面說的url上了,還是404哦
擴展文件沒創(chuàng)建就是404,我的擴展代碼需要加
回復@master888
回復@齊云電商
文件加了啊,是按照你的方法創(chuàng)建的Tiao文件呢,應該怎么調整哦
感謝 @往事別了 的提醒
完整的代碼是
<form id="competitionform22" name="competitionform" action="/index.php" method="GET"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="tiao"> <select name="id" class="makeMeFancy" onchange="document.getElementById('competitionform22').submit(); "> {module module=news catid=18} <option value="{$t.id}">{$t.title}</option> {/module} </select> </form>再新建文件dayrui/app/news/Controllers/Tiao.php,代碼如下
<?php namespace Phpcmf\Controllers; class Tiao extends \Phpcmf\Home\Module { public function index() { $this->_module_init(); $data = $this->content_model->get_data((int)\Phpcmf\Service::L('Input')->get('id')); if ($data) { \Phpcmf\Service::L('Router')->is_redirect_url(dr_url_prefix($data['url'], $this->module['dirname'])); } else { exit("文章不存在"); } } }