Ucenter home Secondary Development Guide

Source: Internet
Author: User

Preface
This article will focus on the core topic of UCH secondary development, with various implementationsCodeThe auxiliary section briefly describes how to perform secondary development for Uch. After a while, uch will be open-source, and you will be prepared to write a detailed uch mechanism analysis later.

By the way, this document was written about two weeks ago, but it has never been time to organize and release. Today I heard that uch will be open-source in the recent period, but it will not be helpful to you again, so I decided not to sort it out, although some of the descriptions in this article are not detailed, they are basically written.

Data Call
Here, data calls are built-in data calls using ucenter home, and "data calls" management is available in "Advanced Applications" in the background. The following Code adds data in the template and then calls data.
1. Intra-site data calling

<! -- {Template data/blocktpl/1} -->

2. js calls outside the site

<Script language = "JavaScript" type = "text/JavaScript" src = "http://www.ccvita.com/js.php? Id = 1 "> </SCRIPT>

Block usage
This block data call is similar to the data call mentioned above in terms of data source and generation ,.

<! -- Demo of block module call -->
<! -- {Block/SQL/select % 20% 2a % 20 from % 20uchome_blog % 20 order % 20by % 20 Dateline % 20 DESC % 20 limit % 200% 2c8/cachename/test/cachetime/0} -->
<! -- {Loop $ _ sblock ['test'] $ value} -->
<Li class = "app-thread"> <a href = "Space. php? Uid = $ value [uid] & Do = Blog & id = $ value [blogid] "> $ value [subject] </a> </LI>
<! -- {/Loop} -->

Eval usage
The eval syntax in the ucenter home template syntax isProgramTo reduce the difficulty of secondary development. For example:
1. Execute PHP statements in the template using the eval syntax

<! -- Eval usage demo -->
<! -- {Eval echo '<li class = "app-thread"> <a href = "do. php? AC = Demo "> <strong> latest log demo </strong> </a> ';} -->

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

<! -- Use eval to include external files -->
<! -- {Eval include 'demo. php'} -->

Note: by introducing external files in the template, you can do anything you want.

Direct external file
Do. php Extension
1.First, Add the allowed new methods to the do. php file.
That is

$ ACS = array ('login', 'comment', 'Wall', 'Register ', 'lostpasswd', 'swfupload', 'inputpwd ',
'Sns ', 'viewspace', 'latekw', 'ajax', 'seccode ');

Add

$ ACS [] = 'Demo ';

2.ThenCreate the do_demo.php file in the source directory. The call address is do. php? AC = demo
Although the files published by uch are encrypted information, we can obtain valuable information for uch secondary development from their open-source files.
For example, the/source/cron directory and the source/class_mysql.php file are both open-source. We can find out some useful information about uch secondary development, such as how to perform SQL queries, through analysis, we can write the following files.

<? PHP
! Defined ('in _ uchome ') & Exit ('Access denied ');

$ Query = $ _ sglobal ['db']-> query ('select * from '. tname ('blog'). 'order by Dateline DESC limit 10 ');
$ Bloglist = array ();
While ($ value = $ _ sglobal ['db']-> fetch_array ($ query )){
$ Bloglist [] = $ value;
}
Include template ('Do _ demo ');
?>

Template File templates/default/do_demo.htm content 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 ('Y-m-d h: I ', $ value [Dateline])} --> </span>
</Div>
<Div class = "status">
<! -- {If $ value [viewnum]} --> <a href = "Space. php? Uid = $ value [uid] & Do = Blog & id = $ value [blogid] "> $ value [viewnum] Times </a> <SPAN class =" pipe "> | </span> <! -- {/If} -->
<! -- {If $ value [replynum]} --> <a href = "Space. php? Uid = $ value [uid] & Do = Blog & id = $ value [blogid] # comment "> $ value [replynum] comments </a> <! -- {Else} --> no comment <! -- {/If} -->
</Div>
</LI>
<! -- {/Loop} -->
</Ul>
</Div>
</Div>
</Div>

<! -- {Template footer} -->

Summary
Although the current uch is not yet open-source, it can be completely modified on the template interface. When the above data calling mechanism is used properly, there are few page effects and data calling requirements that we cannot implement.

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.