windows环境下,smarty模版路径的问题?

lyf1670884 2005-12-22 09:36:04
路径定义:$smarty->assign('ROOTPATH' ,$rootpath."" )/怀疑是不是这句有问题,
调用变量:$smarty->assign('catalog',$catalog );//$catalog是路径变量
引用文件:{include file="news/$catalog/pageheader.tpl"}
------------------------------------------------

(linux下是正确的,在windows下出现错误:
unable to read template resource: "news//pageheader.tpl"
好像是$catalog不起作用???
...全文
189 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
johnpanq 2005-12-22
  • 打赏
  • 举报
回复
修改这几行
<?php
require_once('../base.php');
if($_REQUEST[catalog]=="0103"){
$GLOBALS['rows']=5;
}
?>

修改后
<?php
require_once('../base.php');
global $catalog;
$catalog = $_GET['catalog'];
if($catalog == "0103")
{
$GLOBALS['rows']=5;
}
?>
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
看一条新闻的内容,如index.php?func=detail&catalog=0101&newsid=410
应该是赋值了呀?程序也没错呀
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
$catalog值应从这来的:
帮我看一下,楼上兄弟
<?php
require_once('../base.php');
if($_REQUEST[catalog]=="0103"){
$GLOBALS['rows']=5;
}
?>

<?
//ÁбíÏÔʾÄÚÈÝ
function listAll(){
global $db , $func ,$smarty ;

$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_REQUEST[catalog]' ";

$selectSql .=" order by news_seq desc ";


mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_REQUEST['page'] ? $_REQUEST['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}

$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}

#ÏêϸÄÚÈÝ
function Detail(){
global $db , $func ,$smarty;

$selectSql = "select * from $GLOBALS[news_table] where news_id = " . $db->Quote($_REQUEST[newsid]) ." ";
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('row',$row );
$smarty->assign("func", $func);
$smarty->assign("catalog", $GLOBALS[catalog]);


}
}

//ÁбíÏÔʾÄÚÈÝ
function listSearch(){
global $db , $func ,$smarty, $query_var, $keywords;

$selectSql = "select * from $GLOBALS[news_table] where news_type = '$_REQUEST[catalog]' ";
if($query_var=="0"){
$selectSql.=" and news_title like '%$keywords%' ";
}else{
$selectSql.=" and news_content like '%$keywords%' ";
}
$selectSql.=" order by news_id desc ";
//echo $selectSql;
mylog(__LINE__,"selectSql=$selectSql");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
//$rs = $db->Execute($selectSql);
$page = $_REQUEST['page'] ? $_REQUEST['page'] : 1;
$nrows = $GLOBALS['rows'];
$rs = $db->PageExecute($selectSql, $nrows, $page);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$rs_arr = $rs->GetArray();
$smarty->assign('rs_arr',$rs_arr );
if($rs->AtFirstPage()){
$prevpage = 1 ;
}else{
$prevpage = $page -1 ;
}
if($rs->AtLastPage()){
$nextpage = $page ;
}else{
$nextpage = $page +1 ;
}

$smarty->assign("prevpage", $prevpage);
$smarty->assign("nextpage", $nextpage);
$smarty->assign("catalog", $GLOBALS[catalog]);
$smarty->assign("func", $func);
}
}

#ÏÔʾµ±Ç°Î»ÖÃ
function location(){
global $db , $func ,$smarty, $catalog, $keywords;

$selectSql = "select * from $GLOBALS[catalog_table] where cat_code = '" . substr($_REQUEST[catalog],0,2) ."' ";

$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location1',$row[cat_name] );
}

$selectSql = "select * from $GLOBALS[catalog_table] where cat_code = " . $db->Quote(substr($_REQUEST[catalog],0,4)) ." ";
$rs = $db->Execute($selectSql);
if($db->ErrorMsg()){
mylog(__LINE__,"Db Error" . $db->ErrorMsg() );
}else{
$row = $rs->FetchRow();
$smarty->assign('location2',$row[cat_name] );
}
$smarty->assign('catalog',$catalog );
$smarty->assign('keywords',$keywords );

}


location();

if($func=="listAll"){
listAll();
}else if($func=="detail"){
Detail();
}else if($func=="search"){
listSearch();
}

$smarty->display('index.tpl');

?>
下面是index.tpl调用的语句
{include file="news/$catalog/pageheader.tpl"}
johnpanq 2005-12-22
  • 打赏
  • 举报
回复
news//pageheader.tpl 对应 news/$catalog/pageheader.tpl
所以应该看看$catalog的输出,你现在$catalog是空值,应该是非空才对!
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
还是一样呀,救命呀大哥
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
整个网站的所有代码吗?
johnpanq 2005-12-22
  • 打赏
  • 举报
回复
$_REQUEST全改为$_GET
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
不行,一样
好像是整个detail.tpl都不启作用,标题、内容等都没显示
会不会跟$row = $rs->FetchRow();
$smarty->assign('row',$row );
其中的fetchrow()函数有关?
johnpanq 2005-12-22
  • 打赏
  • 举报
回复
linux下是正确的,所以在winodws下的php的版本和php.ini最好都跟linux下一致。
根本原因是程序的兼容问题。
$_REQUEST是无法区分get和post方式。
johnpanq 2005-12-22
  • 打赏
  • 举报
回复
php.ini中的register_globals = off 改为register_globals = on
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
index.tpl中调用detail.tpl。
detail.tpl中有句显示内容的:
{$row.news_content}
lyf1670884 2005-12-22
  • 打赏
  • 举报
回复
好了,但内容显示不出来了呀,

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧