Home > php教程 > PHP开发 > body text

UCenter Home Secondary Development Guide

高洛峰
Release: 2016-12-30 16:48:05
Original
1330 people have browsed it

Preface
This article will focus on the core theme of secondary development of UCH, focusing on the codes of various implementations. The auxiliary part will briefly explain how to carry out secondary development for UCH. UCH will be open sourced in a while, and I will write a detailed analysis of the UCH mechanism when the time comes.

By the way, this document was written about two weeks ago, but I haven’t had time to compile and publish it. Today I heard that UCH will be open sourced in the near future. Publishing it by then will not be of much help to everyone, so I decided not to organize it anymore. Although some of the instructions in the article are not detailed yet, they have been basically written.

Data call
The data call here is to use the built-in data call of UCenter Home. There is "data call" management in the "Advanced Application" in the background. The following codes are added in the template and then called data.
1. In-site data call

<!--{template data/blocktpl/1}-->
Copy after login

2. Off-site JS call

<script language="javascript" type="text/javascript" src="http://www.ccvita.com/js.php?id=1"></script>
Copy after login

Use of block
This block data call is different from the previous data call, from the data source and In terms of generation, it is basically similar.




  • $value[subject]

    Use of eval
    Reasonable use of the eval syntax in the Ucenter Home template syntax will reduce secondary development in certain programs difficulty. For example:
    1. Execute PHP statements in the template through eval syntax


    2. Introduce an external PHP file through eval syntax
    Introduce external files


    Note: You can do anything you want by introducing external files into the template.

    Direct external file
    Extension of do.php
    1. First, add a new allowed method in the do.php file
    That is, in

    $acs = array ('login', 'comment', 'wall', 'register', 'lostpasswd', 'swfupload', 'inputpwd',
    'sns', 'viewspace', 'relatekw', 'ajax', 'seccode ');

    add

    $acs[] = 'demo';

    2. Then, create a new do_demo.php file in the source directory, and the calling address is do .php?ac=demo
    Although the files released by UCH are encrypted information, we can obtain valuable information for UCH secondary development from its open source files.
    For example, the /source/cron directory and the source/class_mysql.php file are all open source. We can find out some information that is very useful for secondary development of UCH, such as how to perform SQL queries. Through analysis, We can write the following file.

    < ?php
    !defined(&#39;IN_UCHOME&#39;) && exit(&#39;Access Denied&#39;);
    $query = $_SGLOBAL[&#39;db&#39;]->query(&#39;SELECT * FROM &#39;.tname(&#39;blog&#39;).&#39; ORDER BY dateline DESC LIMIT 10&#39;);
    $bloglist = array();
    while ($value = $_SGLOBAL[&#39;db&#39;]->fetch_array($query)) {
    $bloglist[] = $value;
    }
    include template(&#39;do_demo&#39;);
    ?>
    Copy after login

    The content of the template file templates/default/do_demo.htm is

    <!--{template header}-->
    <div class="side_right">
    <div class="wide">
    <div class="post_list">
    <ul>
    <!--{loop $bloglist $value}-->
    <li>
    <div class="title">
    <h4><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]">$value[subject]</a></h4>
    <a href="space.php?uid=$value[uid]">$value[username]</a> <span class="time"><!--{date(&#39;Y-m-d H:i&#39;,$value[dateline])}--></span>
    </div>
    <div class="status">
    <!--{if $value[viewnum]}--><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]">$value[viewnum] 次阅读</a><span class="pipe">|</span><!--{/if}-->
    <!--{if $value[replynum]}--><a href="space.php?uid=$value[uid]&do=blog&id=$value[blogid]#comment">$value[replynum] 个评论</a><!--{else}-->没有评论<!--{/if}-->
    </div>
    </li>
    <!--{/loop}-->
    </ul>
    </div>
    </div>
    </div>
    <!--{template footer}-->
    Copy after login

    Summary
    Although the current UCH is not open source, it is fully modifiable in the template interface and makes reasonable use of the above data calling mechanism. In this case, there are few page effects and data call requirements that we cannot achieve.

    For more articles related to UCenter Home secondary development guide, please pay attention to 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 Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!