今天为了从数据库内提取数据,但是diy有的时候无法满足所以只有自己定义sql语句了
首先创建一个php文件block_sql.php放入./source/class/block/html
文件的内容如下:- <?php
- /**
- *
- * diy调用 进行自定义sql语句
- * 把此文件放入./source/class/block/html内进行使用 ,不要忘了 删除模板缓存 否则是没有效果的
- */
- if (! defined ( 'IN_DISCUZ' )) {
- exit ( 'Access Denied' );
- }
- require_once libfile ( 'commonblock_html', 'class/block/html' );
- class block_sql extends commonblock_html {
- function block_sql() {}
- function name() {
- return lang('blockclass', 'blockclass_html_script_sql');//返回一个模块的名字(在./source/language/lang_blockclass.php内进行定义)
- }
- function getsetting() {
- global $_G;
- $settings = array (
- 'title' => array (
- 'title' => 'sql_title',
- 'type' => 'textarea',
- 'default' => 'SELECT * FROM `pre_forum_forum`'
- ),
- 'template' => array (
- 'title' => 'sql_template',
- 'type' => 'textarea',
- 'default' => '[node]{name}<BR>[/node]'
- ), //自定义html
- 'start' => array (
-
- 'title' => 'sql_start',
- 'type' => 'text',
- 'default' => 0
- ),
- 'limit' => array (
- 'title' => 'sql_limit',
- 'type' => 'text',
- 'default' => 5
- )
- );
- return $settings;
- }
复制代码
然后在diy的时候就可以看到如下的效果:
|