Home  >  Article  >  CMS Tutorial  >  How to replace the home page in phpcms

How to replace the home page in phpcms

尚
Original
2019-10-30 11:41:222854browse

How to replace the home page in phpcms

How to replace the homepage with phpcms:

First make a static corporate website homepage:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <style type="text/css">
        ul li{
            list-style: none;
            display: block;
            position: relative;
            float: left;
            width: 100px;
             
             
        }
        ul{
            height: 50px;
        }
        .base{
            color: #000000;
        }
        .col{
            color: #0000FF;
        }
         
        ul li a{
            text-decoration: none;
             
        }
        #header{
            width: 1200px;
            height: 50px;
            border: solid 2px #000000;
        }
         
        #footer{
            width: 1200px;
            height: 50px;
            border: solid 2px #000000;
        }
        .list{
            position: relative;
            width: 500px;
            height: 250px;
            margin-left: 50px;
            border: solid 2px #000000;
            margin-top: 10px;
            float: left;
        }
        #content{
            width: 1200px;
            height: 550px;
        }
    </style>
    <body>
         <div id="header">
        <ul>
            <li ><a class="col" href="">首页</a></li>
            <li ><a class="base" href="">新闻</a></li>
            <li ><a class="base" href="">公告</a></li>
            <li ><a class="base" href="">关于我们</a></li>
            <li ><a class="base" href="">加入我们</a></li>
        </ul>
         
    </div>
     
    <div id="content">
        <div class="list">新闻<span style="padding-left: 430px;"><a href="#">更多</a></span> <p>腐败发布啊</p></div>
        <div class="list">公告<span style="padding-left: 430px;"><a href="#">更多</a></span><p>大牛坊三年级</p></div>
        <div class="list">关于<span style="padding-left: 430px;"><a href="#">更多</a></span><p>打你叫你</p></div>
        <div class="list">招聘<span style="padding-left: 430px;"><a href="#">更多</a></span><p>的毛囊烦恼</p></div>
    </div>
     
    <div id="footer">
        <ul>
            <li ><a class="base" href="">友情链接</a></li>
            <li ><a class="base" href="">链接1</a></li>
            <li ><a class="base" href="">链接2</a></li>
            <li ><a class="base" href="">链接3</a></li>
            <li ><a class="base" href="">链接4</a></li>
        </ul>
    </div>
    </body>
</html>

Operation effect:

How to replace the home page in phpcmsPut the JS and CSS files in the web page to the corresponding location under the statics folder.

How to replace the home page in phpcms

And modify the file address according to the following format:

Replacement method:

{CSS_PATH} represents the CSS storage path defined by CMS

{JS_PATH} represents the JS storage path defined by CMS

{IMG_PATH} represents the image storage path defined by CMS

How to replace the home page in phpcms

1. Setting requirements Template used

Change the default template in phpcms to the template you made.

Create a new English folder in phpcms/install_package/phpcms/templates

How to replace the home page in phpcms

Create a content folder under this folder

How to replace the home page in phpcms

Change the created .html web page file name to index.html and put it into the content folder

How to replace the home page in phpcms

Log in to the phpcms background, You can see that the newly added template

How to replace the home page in phpcms

will be displayed in the interface-》Template Style-》Select the template style in Site Management and click OK.

How to replace the home page in phpcms

Update the cache and generate the home page

How to replace the home page in phpcms

How to replace the home page in phpcmsAt this time, click on the home page of the site and you will see that the template has been changed successfully :

1How to replace the home page in phpcms

2. Split the template

Split the template into header code, content code, and tail code

Create new headers respectively The content part of .html footer.html is still retained in index.html

Add the code {template "content","header"} to the head of index.html to import header.html

Add the code {template "content","footer"} at the end of index.html to import footer.html

3. Add the column

in the header. In html

first add a link to the navigation bar:

Change

<ul>
            <li ><a class="col" href="">首页</a></li>
            <li ><a class="base" href="">新闻</a></li>
            <li ><a class="base" href="">公告</a></li>
            <li ><a class="base" href="">关于我们</a></li>
            <li ><a class="base" href="">加入我们</a></li>
        </ul>

to:

{pc:content action="category" catid="0" num="5" siteid="$siteid" order="listorder ASC"}
            <ul >
            <li><a class="base" href="{siteurl($siteid)}"><span>首页</span></a></li>
            {loop $data $r}
            <li><a class="base" href="{$r[url]}"><span>{$r[catname]}</span></a></li>
            {/loop}
            </ul>
        {/pc}

num is the maximum number of columns

If you want to increase the navigation monitoring effect, add the code:

<div id="header">
         <ul>
            {if $top_parentid==0}<!--判断首页显示的是不是首页-->
            <li><a href="{siteurl($siteid)}" class="col">首页</a></li> <!--如果是首页,给首页加属性字体显示白色。-->   
            {else}
            <li><a href="{siteurl($siteid)}">首页</a></li><!--如果不是首页,内容正常显示。-->
            {/if}
            {pc:content action="category" catid="0" num="5" siteid="$siteid" order="listorder ASC"}
            {if $catid==$r[catid] || $top_parentid==$r[catid]}<!--判断显示的catid,如果是显示的catid-->
            <li><a href="{$r[url]}" class="col">{$r[catname]}</a></li><!--加属性,字体显示白色-->
            {else}
            <li><a href="{$r[url]}" class="base">{$r[catname]}</a></li><!--如果显示的不是,内容正常显示-->
            {/if}
            {/pc}
         
         </ul>   
         
         
    </div>

Display effect:

1How to replace the home page in phpcms

##Add column:

In the phpcms background , Content-》Add Column in Management Column

Just add the columns that need to be added. Note that the template in the template settings must be modified to the current template.

4. Add content to the column

Modify the code of index.html

First add more internal links:

Code:

<a href="{$CATEGORYS[10][url]}">更多</a>

The number in the middle represents the column code in the phpcms background

Set dynamics for the content of the div:

新闻<a href="{$CATEGORYS[10][url]}">更多</a> {pc:content action="lists" catid="10" num="1" siteid="$siteid" order="id DESC"} {loop $data $r $val}

{$val[title]}

{$val[description]}

{/loop} {/pc}

Recommendation:

php server

The above is the detailed content of How to replace the home page in phpcms. 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