Home >CMS Tutorial >DEDECMS >How to let dedecms implement shtml

How to let dedecms implement shtml

藏色散人
藏色散人Original
2019-12-07 10:50:192244browse

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 &#39;<!--#include virtual="&#39;.$GLOBALS[&#39;cfg_cmspath&#39;].&#39;/data/&#39;.$refObj->Fields[&#39;id&#39;].&#39;right.htm"-->&#39;;
}
}

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[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_templets_dir&#39;]."/".$GLOBALS[&#39;cfg_df_style&#39;]."/right.htm");

Generate html

   $file = $this->Fields[&#39;id&#39;].&#39;right.htm&#39;;
            $rightfile = $GLOBALS[&#39;cfg_basedir&#39;].$GLOBALS[&#39;cfg_cmspath&#39;]."/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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn