Home > CMS Tutorial > DEDECMS > body text

How to let dedecms implement shtml

藏色散人
Release: 2019-12-07 10:50:19
Original
2134 people have browsed it

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;;
}
}
Copy after login

3:Generate When creating a column, the right side of the corresponding column is generated.

   arc.listview.class.php
Copy after login

The code is as follows:

var $tcp1;
var $tcp3;</p> <p> $this->tcp1 = new DedeTagParse();
$this->tcp1->SetRefObj($this);
$this->tcp1->SetNameSpace("dede", "{", "}");
Copy after login

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");
Copy after login

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);
                }
            }
Copy after login

Assign a value to the template

     MakeOneTag($this->tcp1,$this);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!