Home >CMS Tutorial >DEDECMS >How to let dedecms implement shtml
How to let dedecms implement shtml?
Let dedecms implement shtml inclusion. This is a very simple and easy problem. We can realize the top navigation, middle part, public part on the right, and bottom of dedecms through the secondary development of dedecms
Recommended learning: 梦Weavercms
Let dedecms implement shtml inclusion. This is a very simple and easy problem. We can achieve good support for the top navigation, middle part, right public part, and bottom of dedecms through secondary development of dedecms, thereby reducing the frequent consumption of system resources when generating html to generate dedecms html. Function. This can speed up how dedecms generates HTML.
First we need to implement shtml inclusion on the right side of the dedecms column. Regarding the dedecms configuration of the shtml environment, the previous article has described it.
1: First create the right public template templates/default/right.htm
2: Write the following tags
The code is as follows:
function lib_shtml(&$ctag,&$refObj) { if(isset($_GET['tid'])){ return file_get_contents('../data/'.$refObj->Fields['id'].'right.htm'); }else{ return '<!--#include virtual="'.$GLOBALS['cfg_cmspath'].'/data/'.$refObj->Fields['id'].'right.htm"-->'; } }
3:Generate When creating a column, the right side of the corresponding column is generated.
arc.listview.class.php
The code is as follows:
var $tcp1; var $tcp3;</p> <p> $this->tcp1 = new DedeTagParse(); $this->tcp1->SetRefObj($this); $this->tcp1->SetNameSpace("dede", "{", "}");
Load the right.htm template
$this->tcp1->LoadTemplate($GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/right.htm");
Generate html
$file = $this->Fields['id'].'right.htm'; $rightfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_cmspath']."/data/".$file; if(!file_exists($rightfile)){ $this->tcp1->SaveTo($rightfile); }else{ if((time()-filectime($rightfile))>3600){ $this->tcp1->SaveTo($rightfile); } }
Assign a value to the template
MakeOneTag($this->tcp1,$this);
4: Directly call {dede:shtml/}
in the template to generate background, and then let dedecms implement shtml inclusion.
The above is the detailed content of How to let dedecms implement shtml. For more information, please follow other related articles on the PHP Chinese website!