Learn Typecho Theme Development Notes 01,typecho topic notes 01_php Tutorials

Source: Internet
Author: User

Learn Typecho Theme Development Notes 01,typecho Theme Note 01


Blog was accelerated Lok hang out, so there is the idea of learning Typecho theme development, thank you for this opportunity!


The first is to see the theme folder under the ' index.php ', a blog article page generally includes the following basic elements

  • Author
  • Publication time
  • Article categories1 Php2 /**3 * This is a set of default skins for the Typecho 0.9 system4 * 5 * @package Typecho Replica Theme6 * @author Typecho Team7 * @version 1.28 * @link http://typecho.org9 */Ten One if(!defined(' __typecho_root_dir__ '))Exit; A $this->need (' header.php '); -?> - theClass= "Col-mb-12 col-8" id= "main" role= "main" > - While($this-Next()):?> -Class= "POST" itemscope itemtype= "http://schema.org/BlogPosting" > -

    class= "Post-title" itemprop= "name headline" > $this->permalink ()?> "> $this->title ()?>

    +
        class= "Post-meta" >
      • $this->author->permalink ();?> "rel=" author "> $this->author ();?>
      • 21st
      • < time datetime= " $this->date (' C ');?>" itemprop= "datepublished" > $this Date(' F J, Y ');?> time>
      • 22
      • $this->category (', ');?>
      • 23
      • $this->permalink ()?> #comments "> $this->commentsnum (' comments ', ' 1 reviews ', '%d comments ');?>
      • -
      -Class= "Post-content" itemprop= "Articlebody" > - $this->content ('-Read the remainder-');?> - - in Endwhile;?> - to $this->pagenav (' «Previous page ', ' after page» ');?> + - the $this->need (' sidebar.php ');?> * $this->need (' footer.php ');?

    Here is the source code for index.php:

    1 
     Php2 /**3 * This is a set of default skins for the Typecho 0.9 system4  * 5 * @package Typecho Replica Theme6 * @author Typecho Team7 * @version 1.28 * @link http://typecho.org9  */Ten  One if(!defined(' __typecho_root_dir__ '))Exit; A  $this->need (' header.php '); -?> -  theClass= "Col-mb-12 col-8" id= "main" role= "main" > -     
     While($this-Next()):?> -Class= "POST" itemscope itemtype= "http://schema.org/BlogPosting" > -             

    class= "Post-title" itemprop= "name headline" > $this->permalink ()?> "> $this->title ()?>

    +
        class= "Post-meta" >
      • $this->author->permalink ();?> "rel=" author "> $this->author ();?>
      • 21st
      • < time datetime= " $this->date (' C ');?>" itemprop= "datepublished" > $thisDate (' F J, Y ');?> time>
      • 22
      • $this->category (', ');?>
      • 23
      • $this->permalink ()?> #comments "> $this->commentsnum (' comments ', ' 1 reviews ', '%d comments ');?>
      • -
      -Class</span>= "Post-content" itemprop= "Articlebody" > - $this->content ('-Read the remainder-');?> - - in Endwhile;?> - to $this->pagenav (' «Previous page ', ' after page» ');?> + - the $this->need (' sidebar.php ');?> * $this->need (' footer.php ');?>

      Line 2-9 is a comment that contains various information about the subject, with each line beginning with a *.

      @package represents the name of the topic

      @author represents author information

      @version represents the current version of the topic

      @link A link to a website that represents an author

      The include () method is used to include the PHP file to use, see the official PHP Manual include () method

      In the 12,34,35 line can see $this->need (), it in Typecho and the role of the include () is the same

      $this->need (' header.php ');
       
         $this->need (' sidebar.php ');?>
       
         $this->need (' footer.php ');?>

      So the code above is called header.php,sidebar.php,footer.php. The specific three PHP files are what the role of, very simple, as the name implies Oh!

      And then the main body of the article page.

      Class= "Col-mb-12 col-8" id= "main" role= "main" >
       While($this-Next()):?> class= "POST" itemscope itemtype= "http://schema.org/BlogPosting" >

      class= "Post-title" itemprop= "name headline" > $this->permalink ()?> "> $this->title ()?>

          class= "Post-meta" >
        • $this->author->permalink ();?> "rel=" author "> $this->author ();?>
        • < time datetime= " $this->date (' C ');?>" itemprop= "datepublished" > $thisdate< /c8> (' F J, Y ');?> time>
        • $this->category (', ');?>
        • $this->permalink ()?> #comments "> $this->commentsnum (' comments ', ' 1 reviews ', '%d comments ');?>
        Class= "Post-content" itemprop= "Articlebody" > $this</span>->content ('-Read the remainder-');?> Endwhile;?> $this->pagenav (' «Previous page ', ' after page» ');?>

        What the hell is endwhile???? Why do I never use it again? Looked up the following information, originally is a kind of syntax sugar:)

        The subject of the article is from here to the end

         
          while ($thisnext()):?>
         
           endwhile;?>

        : instead of {

        ; instead of}

        See article in detail: Alternative syntax for Process Control in PHP

        And then there are some ways.

         
          $this->permalink ()?>      article where the connection
         
           $this->title ()?>      article title
         
           $ This->author ();?>      article author
         
           $this->author->permalink ();?>      Article author address
         
           $this date(' F J, Y ');?>      article release date, format can refer to PHP date format
         
          $this->category (', ');?>      article is in the category
         
           $this->commentsnum ('%d Comments ');? >      Article comments and links
         
           $this->content (' Continue Reading ... ')?>     article content, where the "  Continue Reading ... " is the text that hides the part when the summary is displayed

        _e () What is this method, specificity and precision 10

        See the next WordPress inside the _e () method, incredibly is used as a translator ... Do Typecho still have crooked nuts to use (Escape

        Print the string directly to the HTML, using _e (). specifically, look here.

        In the code can also see the Itemprop attribute, this is HTML5 new addition, temporarily do not control him q.q

        And finally, a paging method

         
          $this->pagenav ();?>

        At this point, index.php file has been analyzed once, although I do not have PHP foundation, but learned after the discovery is not difficult, hey! Keep trying!

        http://www.bkjia.com/PHPjc/1074252.html www.bkjia.com true http://www.bkjia.com/PHPjc/1074252.html techarticle Learn Typecho Theme Development Notes 01,typecho Theme Notes 01 blog was Accelerated Lok hang off, so there is the idea of learning Typecho theme development, thank you for this opportunity! The first thing is to go to the theme folder ...

      • Contact Us

        The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

        If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

        A Free Trial That Lets You Build Big!

        Start building with 50+ products and up to 12 months usage for Elastic Compute Service

        • Sales Support

          1 on 1 presale consultation

        • After-Sales Support

          24/7 Technical Support 6 Free Tickets per Quarter Faster Response

        • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.