PageNo>1)" above the "Display" function {$tempfile...}" will do."/> PageNo>1)" above the "Display" function {$tempfile...}" will do.">
Home > Article > CMS Tutorial > 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();
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); }
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);
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(); }
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";
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";
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!