需求是这样的:
我要在门户的首页把频道栏目循环出来,所以要在index.htm页面中做一个loop循环,即然是loop,那么肯定要给它一个数组,即存放频道栏目的数据表 portal_category,
我的疑惑有两点,
一, 如果要用系统自带的定义数据表的方法,那么,我怎么知道这个数据表定义在哪个数组中呢?
二,如果我自己定义,那么这个数组sql出来的语句我要写在哪里呢?
回复讨论(解决方案)
打开:\source\module\portal\portal_index.php
在include_once template上面添加:
$res=DB::fetch_all("SELECT * FROM %t",array('portal_category'));
echo "
"; <br> print_r($res); <br> echo "
Copy after login
Copy after login
Copy after login
";
访问门户首页试试
打开:\source\module\portal\portal_index.php
在include_once template上面添加:
$res=DB::fetch_all("SELECT * FROM %t",array('portal_category'));
echo "
"; <br> print_r($res); <br> echo "
Copy after login
";
访问门户首页试试
哦,我忘说了,我用的是discuz!x3.2版本,里面没有 include_once template
我把你说的代码加在红色位置处了,不知行吗,我打印的结果是可以的,但不知这么写 规范吗?
/-------------------------------------------------------------------------------------------
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: portal.php 33234 2013-05-08 04:13:19Z andyzheng $
*/
define('APPTYPEID', 4);
define('CURSCRIPT', 'portal');
require './source/class/class_core.php';
$discuz = C::app();
$cachelist = array('userapp', 'portalcategory', 'diytemplatenameportal');
$discuz->cachelist = $cachelist;
$discuz->init();
require DISCUZ_ROOT.'./source/function/function_home.php';
require DISCUZ_ROOT.'./source/function/function_portal.php';
$res=DB::fetch_all("SELECT * FROM %t",array('portal_category'));
echo "
"; <br> print_r($res); <br> echo "
Copy after login
Copy after login
Copy after login
";
if(empty($_GET['mod']) || !in_array($_GET['mod'], array('list', 'view', 'comment', 'portalcp', 'topic', 'attachment', 'rss', 'block'))) $_GET['mod'] = 'index';
define('CURMODULE', $_GET['mod']);
runhooks();
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['portal']);
$_G['disabledwidthauto'] = 1;
require_once libfile('portal/'.$_GET['mod'], 'module');
?>
你打开的文件错了,你那个是门户的入口文件
你要写在\source\module\portal\portal_index.php文件里
echo "
"; <br> print_r($res); <br> echo "
Copy after login
Copy after login
Copy after login
";
这三句只是为了显示出来给你看,你在前台的模版文件中要loop的数组就是$res,数组名字自己换