Phpcms V9 Most useful 23 calling code

Source: Internet
Author: User
Tags explode browser cache clear browser cache

Share Phpcms V9 The most practical 23 calling code today, you can use it to turn around, which will greatly accelerate your development efficiency.


1, call the latest article, with the section;


{pc:get sql= "select A.title, A.catid, B.catid, B.catname, A.url as Turl, B.url as curl,a.id from ' v9_news ' A, ' v9_category ' b WHERE a.catid = B.catid ORDER by ' a '. ' ID ' DESC "num=" "Cache=" 300 "}

{Loop $data $r}

[{$r [catname]}] {str_cut ($r [' title '],26)}

{/loop}

{/PC}

2, intercept the title length of the call;


{str_cut ($v [' title '],34)}---out of use ... Replace

{str_cut ($v [' title '],34, '??? ')} ---Beyond the use of??? Replace

{str_cut ($v [' title '],34, ')}-----beyond the use of any character instead

3, format time call;


{Date (' y-m-d h:i:s ', $r [inputtime])}-----2013-07-25:11:22:33

{Date (' m-d ', $v [' Inputtime '])}------07-25

4, multi-column call & multi-Referral call Demand: The article range is 59 60 613 columns, and pushed to 27 and 282 recommended bits; Starting with the third, 7 articles are called consecutively.


{pc:get sql= "select * from V9_news where ID in (SELECT ID from V9_position_data where Posidin (27,28) and CATID in (59,60,61 ) Order by Listorder DESC "cache=" 3600 "start=" 3 "num=" 7 "return=" Data "}

{Loop $data $n $r}

· {Str_cut ($r [title],22, ')}

{/loop}

{/PC}

5. Display the name of the column;


{$catname}-----only show names without links

{$CATEGORYS [$r [' catid ']][' catname ']}-----Show column names and links

6, get the parent column ID/get the parent column name;


{$CATEGORY [$catid][parentid]}-----parent Column ID

{$CATEGORYS [$CAT [parentid]][catname]}-----Parent column Name

7, external data source call Dedecmsdb in the background data source add;


{pc:get sql= "select * from Cq_member where mtype= ' Enterprise '" cache= "3600" dbsource= "Dedecmsdb" num= "7" return= "Data"}

{Loop $data $r}

{Str_cut ($r [uname],28, ')}

{/loop}

{/PC}

8, call sub-column (in the column home template needs to use);


{pc:content action= "category" Catid= "$catid" num= "siteid=" $siteid "order=" LISTORDERASC "}

{Loop $data $r}

{$r [catname]} | {/loop}

{/PC}

9, display the name of the column of the specified ID;


{$CATEGORYS [22][' CatName ']}

10. Display the article category before the article;


{pc:content action= "lists" catid= "" order= "Listorder DESC" num= "14"}

{Loop $data $n $r}

{if $TYPE [$r [Typeid]][name]} [{$TYPE [$r [Typeid]][name]}]

{/if} {Str_cut ($r [title],33, ')}

{/loop}

{/PC}

11, the specified variable cycle growth (slides are often used);


{pc:content action= "lists" catid= "5" order= "Listorder DESC" thumb= "1" num=

{php $num = 0}

{Loop $data $r}

linkarr[{$num}] = "{$r [url]}";p icarr[{$num}] = "{$r [thumb]}"; textarr[{$num}] = "{str_cut ($r [title],36, ')}";

{PHP $num + +}

{/loop}

{/PC}

12, the article calls use limit;


{pc:content action= "position" posid= "order=" Listorder DESC "limit= ' 1,8--'}

{Loop $data $r}

{Str_cut ($r [title],36, ')}

{/loop}

{/PC}

13, the article starts from the specified position to call the starting position is 5, calls 3;


{pc:content action= "position" posid= "order=" Listorder DESC "num=" 3 "start=" 5 "}

{Loop $data $r}

{Str_cut ($r [description],115)} ...

{/loop}

{/PC}

[Page]

14, the article List page call keyword, or the first page call keyword NOTE: explode (', ', $r [keywords]); is the article keyword through the comma separated, that is, each article to be a comma interval keyword, otherwise called out will be all as a key word. If it is a space interval keyword, the explode (', ', $r [keywords]) will be changed to explode (", $r [keywords]);


{pc:content action= "lists" catid= "$catid" num= "order=" "id DESC" page= "$page"}

{Loop $data $r}

{$r [title]}

{php $keywords = explode (', ', $r [keywords]);}

Article Tags:

{Loop $keywords $keyword}

{$keyword}

{/loop}

{/PC}

15, whenever the list of a few lines of time appear some symbols (such as the first page of the article recommendation, a row of two, in the middle of the two want to add a vertical line | To use this code) a large number of words will be prone to error, because the modulo operation oh but generally also 4 headings below;


{pc:content action= "position" posid= "8" order= "Listorder DESC" num= "2"}

{Loop $data $r}

{Str_cut ($r [title],26, ')} {if $n%2==1} | {/if}

{/loop}

{/PC}

16, V9 list page Perfect support custom segment call;


{pc:content action= "lists" catid= "$catid" num= "order=" "id DESC" page= "$page" moreinfo= "1"}

{Loop $data $r}

[{$r [' field name ']}]> {$r [title]}

{/loop}

{$pages}

{/PC}

[Page]

17, the current column calls the parent and the following column information method other code;


{php $arrchildid = $CATEGORYS [$CAT [Parentid]][arrchildid]}

{pc:get sql= "select * from V9_news where catid in ($arrchildid) cache=" 3600 "page=" $page "num=" \ "return=" Data "}

18, V9 How to return the current page after the form function is submitted, but not the default home file address;


Find the 73rd line of the phpcms\modules\formguide\index.php file


ShowMessage (L (' Thanks '), App_path);


The following code can be modified to automatically return to the previous page


ShowMessage (L (' Thanks '), http_referer);

19, V9 home or page custom field calls and 15 almost the first ordinary list or column calls the custom field after {pc:content action= "lists" plus a sub-table moreinfo=1 (equals 1 o'clock, 0 o'clock not shown) example:


{pc:content action= "lists" Moreinfo=1 catid= "2" order= "id DESC" num= "4"}

{Loop $data $key $val}

{$val [' title ']}

Price: {str_cut ($v [' Custom segment '],100)}//100 is the word count

{/loop}

{/PC}

20, the second recommendation bit call custom field in the model to add a good custom field, you must put "in the recommended bit label" Click "Yes" and then use the same method to adjust the data is OK, remember, if you add the article, you must go to update the article will be displayed, the custom segment in the recommendation only show you choose, Select the previous plus article does not display, update the article shows an example:


{pc:content action= "position" posid= "recommended bit ID" num= "thumb=" 1 "moreinfo=" 1 "order=" Listorder DESC "}

{Loop $data $key $val}

{str_cut ($val [' title '],20)}

{/loop}

{/PC}

21, the editor uploads the image automatically uses the title as the ALT parameter;


One: Modify Statics/js/ckeditor/plugins/image/dialogs/image.js to find accesskey: ' T ', ' Default ': '

Replace with accesskey: ' T ', ' Default ' (' #title '). Val ()

Two: Clear browser cache

22, increase the number of random clicks of the article;


Found 100 rows of $views = $r [' views '] +1 modified to:

$rand _nums=rand (79,186);

$views = $r [' views '] + $rand _nums;

Indicates a click, increasing the range of 79 to 186 times

23, Phpcms V9 the get tag call;


1, call the system single data, example (call ID 1 information, title length of not more than 25 kanji, display update date):


{Get Sql= "select * from Phpcms_content where contentid=1"/}

Title: {str_cut ($r [title], 50)}

url:{$r [url]}

Update Date: {date (' y-m-d ', $r [UpdateTime])}


2, call the system a number of data, example (call column ID 1 through the audit of 10 information, the title length of not more than 25 characters, display update date):


{Get Sql= "select * from Phpcms_content where catid=1 and status=99 order by updatetime Desc" rows= "10"}

Title: {str_cut ($r [title], 50)}

url:{$r [url]}

Update Date: {date (' y-m-d ', $r [UpdateTime])}

{/get}


3, with paging, example (call column ID 1 through the audit of 10 information, title length of not more than 25 characters, display update date, with pagination):


{Get Sql= "select * from Phpcms_content where catid=1 and status=99 order by updatetime Desc" rows= "" Page= "$page"}

Title: {str_cut ($r [title], 50)}

url:{$r [url]}

Update Date: {date (' y-m-d ', $r [UpdateTime])}

{/get}

Paging: {$pages}


Phpcms V9 Most useful 23 calling code

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.