帝国CMS常用功能汇总(4)

By kaqishe
In 杂碎
2020-12-17
网络

帝国cms获取当前栏目的 父栏目id 的方法

<?php

if($class_r[$GLOBALS[navclassid]][bclassid]==0){

$classid=$GLOBALS['navclassid'];

$classname=$class_r[$classid][classname];

}else{

$classid=$class_r[$GLOBALS[navclassid]][bclassid];

$classname=$class_r[$classid][classname];

}

?>

在模板中插入以上代码

如果当前栏目的父栏目id为0 就直接 获取当前栏目 id $GLOBALS['navclassid'];

内容页调用图片集

 <?php

 $data1=$empire->query("select morepic from phome_ecms_photo_data_1 where classid=".$_GET['classid']." and id=".$_GET['id'] ." "); 

 $data=$empire->fetch($data1 ); 

$arry=explode("\\r\\n",$data[0]);

foreach($arry as $singarry)

  {

  $arry2=explode("::::::",$singarry);

 echo '<div><img src="'. $arry2[1].'"/></div>';

 }

 ?>

说明:

$arry2[0]为小图地址,$arry2[1]为大图地址,$arry2[2]为图片说明


下面和上面类似

<?php

$fr=$empire->fetch1("select * from {$dbtbpre}ecms_photo_data_1 where id=8");

$rr=explode("\\r\\n",$fr[morepic]);

$count=count($rr);

$listtemp="";

for($i=0;$i<$count;$i++)

{

$frt=explode("::::::",$rr[$i]);

$listtemp.=('<a href="'.$frt[1].'"><img src="'.$frt[0].'"></a>');

}

$listtemp=('<div id="'.$fr[id].'">'.$listtemp.'</div>');

?>

<?=$listtemp?>

说明:

$frt[0] 为小图,$frt[1]为大图,$frt[2]为图片说明


内容页根据关键词来调用相关内容

<?php

if ($navinfor['keyboard'])

{

$c_key=explode(',',$navinfor['keyboard']);

$count=count($c_key);

for($i=0;$i<$count;$i++)

{

if($i==0)

{

$or='';

}

else

{

$or=' or ';

}

$repadd.=$or."keyboard like '%".$c_key[$i]."%'";

}

$r=$empire->fetch1("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 1");

if($r[title])

{

$mesql=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 10");

while($or=$empire->fetch($mesql))

{

$newstime=date('Y-m-d',$or[newstime]);

?>

<li><a href="<?=$or[titleurl]?>"><?=$or[title]?></a><span><?=$newstime?></span></li>

<?

}

}

else

{


$mesql2=$empire->query("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." order by rand() desc limit 10");

while($r2=$empire->fetch($mesql2))

{

$newstime=date('Y-m-d',$o2[newstime]);

?>

<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>

<?

}

}

}

else

{

$mesql2=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news order by rand()  desc limit 10");

while($r2=$empire->fetch($mesql2))

{

$newstime=date('Y-m-d',$r2[newstime]);

?>

<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>

<?

}

}

?>


帝国CMS常用功能汇总(3)
帝国CMS常用功能汇总(5)