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&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 <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&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>