Ucenter Home Two development guide _php tips

Source: Internet
Author: User

Objective
This article will be uch two development of this core theme, with a variety of implementation of the Code, the auxiliary part of the outline of how to uch for the two times development. After a period of time uch on the open source, ready to write a detailed uch mechanism analysis.

By the way, this paper written in about two weeks ago, but there has been no time to organize the release, today heard that Uch will be in the recent period of open source, and then again to help not to everyone, so decided not to finish, although some of the text is not detailed, but has been basically written.

Data invocation
Here the data call is using the Ucenter home built-in data call, in the background of the "Advanced application" in the "Data call" management, the following code is added in the template, and then call the data.
1. In-station data call

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

2. Outside the station JS call

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

Use of block
This block data call and the preceding call to the data are basically similar from data sources and builds.

<!--block Module invoke demo-->
<!--{block/sql/select%20%2a%20from%20uchome_blog%20order%20by%20dateline%20desc%20limit%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}-->

Use of Eval
Reasonable use of the Eval syntax in the Ucenter home template syntax will reduce the difficulty of two development in a certain program. Like what:
1. Execute PHP statements within a template through 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 the eval syntax
Introducing external files

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

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

Direct External File
Extension of the do.php
1. first , add the new allowed method in the do.php file
namely in

$acs = Array (' login ', ' comment ', ' wall ', ' register ', ' lostpasswd ', ' swfupload ', ' inputpwd ',
' SNS ', ' viewspace ', ' relatekw ', ' Ajax ', ' Seccode ');

Add after

$acs [] = ' demo ';

2. then , in the source directory, create a new do_demo.php file, the calling address is Do.php?ac=demo
Although the Uch release file is encrypted, we can derive valuable information from its already open source file for Uch two of times.
For example,/source/cron this directory and source/class_mysql.php files are open source, we can find out, for the Uch Two development is very useful for some information, such as how to do SQL query, through analysis, we can write the following file.

< 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" >
<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] Second reading </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 Comments <!--{/if}-->
</div>
</li>
<!--{/loop}-->
</ul>
</div>
</div>
</div>

<!--{Template footer}-->

Summarize
Although the current uch is not open source, but in the template interface is completely modifiable, reasonable use of the above data invocation mechanism, rarely we can not achieve the page effect and data invocation requirements.

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.