杨庆荣的博客

工作之余接单:公司产品展示网站建设、电商网站建设、小程序、app开发。+86 13714715608

discuz x2 插件笔记一

点击 1870    创建时间 2012-10-22 18:00:04

<p> <strong>1</strong>.引入插件模板{subtemplate 插件名:文件名},例如: {subtemplate wudimei:side}</p> <p> <strong>2</strong>.在php中引入模板 include template("wudimei:main_index");</p> <p> <strong>3</strong>.$_G[uid]表示当前的用户编号,$_G["gp_xxx"]表示$_GET["xxx"],其中xxx是get的参数名称。 例如plugin.php?id=wudimei:main&amp;op=main , 可以用 $_G["gp_op"]来取得op的值"main"。</p> <p> <strong>4</strong>.DB::result_first( $sql )取得结果集的第一行第一列的值,也就是第一个单元格的数据。</p> <p> <strong>5</strong>.分页:<br /> $uid = intval( @$_G["uid"] );<br /> $page = intval( @$_G["gp_page"] );<br /> if( $page &lt;1) $page =1;<br /> $pageSize = 5;<br /> $startIndex = ( $page -1 ) . $pageSize;<br /> $sql = "select count(id) from " . DB::table("wudimei_contact") . " where uid=" . $uid;<br /> $recordCount = DB::result_first( $sql );<br /> $pageBar = multi($recordCount, $pageSize, $page, "plugin.php?id=wudimei:main&amp;action=index" );<br /> $sql = "select * from " . DB::table("wudimei_contact") . " where uid=" . $uid . " order by id desc limit " . $startIndex . "," . $pageSize;<br /> $query = DB::query( $sql );<br /> $rows = array();<br /> while( $row = DB::fetch( $query ) ) { $rows[] = $row ; }</p>

上一篇: ios写的简单计算器
下一篇: rong framework 重写init()方法以改变视图的存放路径