Today, there are many articles on zblog php calling code, mainly to sort out some common local code into the blog, so that you can directly copy it when using it in the future, save every time you need to use it, search for it in other local topics. When creating a blog topic, you can call the TAG on the content page, sidebar, or bottom bar, and use the article abstract in the article list, in this way, we can manually set the abstract when writing an article, and control the number of words intercepted in a unified manner.
1. Summary of ZBP article list
1. Default style
The code is as follows: |
Copy code |
{$ Article. Intro}
|
In this way, we call the abstract section at the bottom of the editor when editing and publishing an article. This requires you to manually set the content and word count control before publishing an article. In fact, we generally prefer this method.
2. Automatically intercepts the content's word summary
The code is as follows: |
Copy code |
{Php} $ intro = preg_replace ('/[\ r \ n \ s] +/', '', trim (SubStrUTF8 (TransferHTML ($ article-> Content, '[nohtml]'),
120). '...'); {/Php}
{$ Description}
|
This automatically intercepts the ZBP text part with 120 characters, which can be controlled by the number of words.
3. Automatic screenshot summary
The code is as follows: |
Copy code |
{Php} $ intro = preg_replace ('/[\ r \ n \ s] +/', '', trim (SubStrUTF8 (TransferHTML ($ article-> Intro, '[nohtml]'),
120). '...'); {/Php}
{$ Description}
|
This method automatically intercepts the number of abstract words, because we sometimes want to have the same number of abstract words when submitting the content. You can use this method.
Second, zbp tag call
Tags are generally used for keywords in a single article to obtain the relevance of the article (related article calls), and we need to call the side or a specific location to connect the entire website.
1. TAG keywords of a single article
The code is as follows: |
Copy code |
{Foreach $ article. tags as $ tag} <a href = "{$ tag. url} "target =" _ blank "> {$ tag. name} </a> & nbsp; {/foreach}
|
Generally, this is used to call the TAG keyword under the title of the article.
2. Random Tag call
The code is as follows: |
Copy code |
Function zbp_random_tags (){
Global $ zbp, $ str;
$ Str = '';
$ Array = $ zbp-> GetTagList ('','', array ('rand () '=> ''), array (
10),'');
Foreach ($ array as $ tag ){
$ Str. = "<a href = \" {$ tag-> Url} \ "title = \" {$ tag-> Name} \ ">{$ tag-> Name} </ a> ";
}
Return $ str;
}
|
Put the above code in the inculde. Php file of the current topic, and then use it at the location to be called up:
The code is as follows: |
Copy code |
{Php} echo zbp_random_tags (); {/php}
|
3. Call based on the number of Tag tags
The code is as follows: |
Copy code |
Function zbp_hot_tags (){
Global $ zbp, $ str;
$ Str = '';
$ Array = $ zbp-> GetTagList ('','', array ('tag _ count' => 'desc'), array (
10),'');
Foreach ($ array as $ tag ){
$ Str. = "<a href = \" {$ tag-> Url} \ "title = \" {$ tag-> Name} \ ">{$ tag-> Name} </ a> ";
}
Return $ str;
}
|
Similarly, add the code to the include. Php file of the current topic, and call up the location and paste the code:
The code is as follows: |
Copy code |
{Php} echo zbp_hot_tags (); {/php}
|
To sum up, we can automatically call the required modules when creating the ZBP topic.