Home > CMS Tutorial > DEDECMS > body text

How to use different templates for the homepage of DEDECMS list page and other pages

藏色散人
Release: 2020-01-10 09:25:38
Original
2292 people have browsed it

How to use different templates for the homepage of DEDECMS list page and other pages

How to use different templates for the homepage of DEDECMS list page and other pages?

Home page of DEDECMS list page Ways to use different templates from other pages

Recommended learning:梦Weavercms

Sometimes we need to make the first page of the list page different from the second page and subsequent pages The styles are different, and it is difficult to achieve the desired effect by modifying the dede:list tag. So Dreamweaver Cat will introduce you to the simplest method, which is to specify a separate template page for the homepage, and call another template page for the other pages.

The modification method is as follows:

Open the arc.listview.class.php file in the include directory, find the Display function (about line 397), and find the following code :

$this->ParseTempletsFirst();
Copy after login

Add the following code above these codes:

if($this->PageNo>1)
{
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_article2.htm";
$this->dtp->LoadTemplate($tempfile); 
}
Copy after login

After adding, when the number of pages is greater than 1, Dreamweaver will call list_article2.htm as the list page template.

After adding the above code, it can be realized when dynamically browsing the column, but you will find that after generating the static HTML page of the column, the expected purpose is still not achieved.

Search for the following code:

$this->ParseDMFields($this->PageNo,1);
Copy after login

Add the following code above this code:

if($this->PageNo>1)
{
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_article2.htm";
$this->dtp->LoadTemplate($tempfile);
$this->ParseTempletsFirst(); 
}
Copy after login

Okay, now both the static page and the dynamic page have achieved the desired effect.

You may still have questions. If a column has multiple list page templates, should the second page of each column list page use list_article2.htm as the template?

Solution:

Change

$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_article2.htm";
Copy after login

to:

 $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];
 $tempfile = str_replace("{tid}",$this->TypeID,$this->Fields['templist']);
 $tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
 $tempfile = $tmpdir."/".$tempfile;
 $tmpfile2 = substr($tempfile,0,-4);
 $tempfile = $tmpfile2."2.htm";
Copy after login

Now it will automatically get the template with 2 added after the list page template, for example The template of the list page is list_image.htm, then the template of the second page is list_image.htm.

This is much more convenient.

The above is the detailed content of How to use different templates for the homepage of DEDECMS list page and other pages. 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