PHP程序里面
開發(fā)應(yīng)用插件前端調(diào)用問題求大神給個(gè)思路
因?yàn)橐恍┨厥庠?,要開發(fā)一個(gè)產(chǎn)品展示功能,產(chǎn)品分類必須指定的表名稱:cptree,產(chǎn)品表:product
所以只能放棄內(nèi)容模塊,,創(chuàng)建空白應(yīng)用。
先創(chuàng)建好了表與字段,利用開發(fā)者工具,創(chuàng)建數(shù)據(jù)控制器,已經(jīng)實(shí)現(xiàn)了后臺(tái)的數(shù)據(jù)添加修改以及顯示。

但現(xiàn)在前端無從下手了
1、前端需要產(chǎn)品分類列表頁list.html顯示
2、產(chǎn)品搜索功能,以及字段篩選功能。
2、產(chǎn)品詳情show.html顯示,表字段調(diào)用。
大神們給點(diǎn)思路或給個(gè)示例
后臺(tái)數(shù)據(jù)你都能創(chuàng)建控制器管理,說明有一些開發(fā)經(jīng)驗(yàn)了,以下是我的建議思路,僅供參考
1 創(chuàng)建空白控制器,根據(jù)分類id傳入進(jìn)去,再模板使用table標(biāo)簽查詢這個(gè)分類的數(shù)據(jù)
2 需要搜索字段的話,建議參考hy插件的search用法,他是基于內(nèi)容搜索做的搜索member表,異曲同工,有參考意義
3 也是1一樣,創(chuàng)建空白控制器,傳入內(nèi)容id進(jìn)去,然后可以在控制器里面做查詢,也可以在模板里面使用table標(biāo)簽做插查詢,前者更加規(guī)范一些
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
<?php namespace Phpcmf\Controllers; /* /dayrui/App/插件目錄/Controllers/home.php */ class Home extends \Phpcmf\Common { public function index() { // 默認(rèn) /index.php?s=插件目錄&c=home&m=index \Phpcmf\Service::V()->set_dir(dirname(__FILE__).'/../Views/'); \Phpcmf\Service::V()->display('home.html'); } public function list() { // 列表頁面 /index.php?s=插件目錄&c=home&m=list // 產(chǎn)品分類 $data = \Phpcmf\Service::M()->db->query("select * from cptree"); $typelist = []; if ($data){ $rows = $data->getResultArray(); if($rows){ foreach ($rows as $t) { $typelist[] = [ 'id' => $t['id'], 'name' => $t['name'], ]; } } } \Phpcmf\Service::V()->set_dir(dirname(__FILE__).'/../Views/');// 模版目錄為當(dāng)前目錄Views下 \Phpcmf\Service::V()->display('list.html'); } public function show() { // 內(nèi)容頁面 /index.php?s=插件目錄&c=home&m=show&id=xx $id = \Phpcmf\Service::L('Input')->get('id'); $row = \Phpcmf\Service::M()->table('product')->where('id', $id)->getRow(); \Phpcmf\Service::V()->assign([ 'title' => $row['title'], 'content' => htmlspecialchars_decode($row['content']), ]); \Phpcmf\Service::V()->set_dir(dirname(__FILE__).'/../Views/'); \Phpcmf\Service::V()->display('show.html'); } } //list.html {loop $typelist $i $c} {$c.id} {$c.name} {/loop} //show.html <h1>{$title}</h1> <div>{$content}</div>原理就是這樣,其他就靠你寫sql語句了。
public function list() { // 列表頁面 /index.php?s=插件目錄&c=home&m=list // 產(chǎn)品分類 $data = \Phpcmf\Service::M()->db->query("select * from cptree"); $typelist = []; if ($data){ $rows = $data->getResultArray(); if($rows){ foreach ($rows as $t) { $typelist[] = [ 'id' => $t['id'], 'name' => $t['name'], ]; } } } \Phpcmf\Service::V()->assign([ 'typelist' => $typelist, ]); \Phpcmf\Service::V()->set_dir(dirname(__FILE__).'/../Views/');// 模版目錄為當(dāng)前目錄Views下 \Phpcmf\Service::V()->display('list.html'); }list那里少寫了模版變量
其實(shí)…… 空白頁面也可以使用迅睿的標(biāo)簽實(shí)現(xiàn)前端列表,內(nèi)容的展示
content 標(biāo)簽直接套在內(nèi)容頁開頭結(jié)尾
list 頁直接用 module 標(biāo)簽就可以了
參考文檔:《數(shù)據(jù)獲取POST和GET》
這句應(yīng)該不需要的!我寫的沒有這句
感謝大家的幫助,我研究測(cè)試下看