Maobei Blog Head

Mobei Blog

I would like to go to the sea

  • article four thousand seven hundred and thirty-six
  • read two million one hundred and seventy-six thousand seven hundred and twenty

Countdown to life

  • Today has passed hour
  • This week has passed day
  • This month has passed day
  • This year has passed Months

How does zblog PHP program judge page type

Brother Maobei Zblog Tutorial 2023-11-11 14:04:43 five hundred and seventy

In Z-Blog theme development, the first thing we need to do is to judge the page in template/index.php, that is, to determine which template file to call when the page is the first page, which page template to call when it is a category page, tab page, article page, independent page and date page, and even more specifically, which category to call which template file!

To achieve this function, we need to learn to judge the type attribute of the page. The specific code for this purpose is as follows:

{if $type=='index '&&$page=='1'}/* Judge the first page */{if $type=='category '}/* Judge the classification page */{if $type=='article'}/* Judge the log page, excluding independent pages */{if $article. Type==ZC_POST_TYPE_ARTICLE}/* (another scheme) */{if $type=='page '}/* Judge independent pages */{if $type=='author'}/* Judge user pages */{if $type=='date '} /*Judgment date page */{if $type=='tag '}/* Judgment tab*/

Example Usage: Separate the first page from the classified list page

<!-- Make a judgment in the index.php file and separate the template -->{if $type=='index '&&$page=='1'} {template: post index} {else} {template: post list} {/if}

Then create two corresponding template files: post index. php (the original index. php can be renamed) and post list. php (the original index. php can be copied and renamed)

Where post-index.php is the home page, and post-list.php is the list page of other articles except the home page.

 advertisement
Article Contents
    search