Phpcms V9 templates
1. Extract the call title Length
{Str_cut ($ R [title], 36, '')}, which is enclosed in quotation marks to remove ....
2. Format time
Call formatting time 11:22:33
{Date ('Y-m-d h: I: s', $ R [inputtime])}
3. Multi-topic call & multi-Recommendation call
Call requirement: The article covers 59, 60, and 61 topics, and pushed two recommendation positions, 27 and 28;
Start from Article 3 and call seven articles consecutively.
{PC: Get SQL = "select * From v9_news where ID in (select ID from v9_position_data where posid in (27,28) and catid in (59,60, 61 )) order by listorder DESC "cache =" 3600 "Start =" 3 "num =" 7 "return =" data "}
{Loop $ data $ N $ R}
<Li> · <a target = "_ blank" href = '{$ R [url]}' Title = "{$ R [title]}" style = "color: black; ">{ str_cut ($ R [title], 22,'')} </a> </LI>
{/Loop}
{/PC}
4. display the topic name (only name, without link)
{$ Catname}
Show the topic name and link (you can click)
<A href = "{$ categorys [$ R [catid] [url]}"> {$ categorys [$ R ['catid'] ['catname']} </A>
5. Get the parent topic ID/get the parent topic name
{$ Category [$ catid] [parentid]}
Parent topic name: {$ categorys [$ cat [parentid] [catname]}
6. External Data Source call
Add dedecmsdb to the background data source
{PC: Get SQL = "select * From cq_member where mtype = 'business'" cache = "3600" dbsource = "dedecmsdb" num = "7" return = "data "}
{Loop $ data $ R}
<A href = "/member/index. php? Uid = {$ R [userid]} "Title =" {$ R [uname]} "target =" _ blank "> {str_cut ($ R [uname], 28, '')} </a>
{/Loop}
{/PC}
7. Call subtopics (required in the topic homepage template)
{PC: Content action = "category" catid = "$ catid" num = "25" siteid = "$ siteid" Order = "listorder ASC "}
{Loop $ data $ R}
<A href = "{$ R [url]}" >{$ R [catname]} </a> |
{/Loop}
{/PC}
8. display the topic name with the specified ID (catid = 22 in this example)
{$ Categorys [22] ['catname']}
9. display the article category in front of the article
{PC: Content action = "Lists" catid = "79" Order = "listorder DESC" num = "14 "}
<? PHP $ type = getcache ('Type _ content', 'commons');?>
{Loop $ data $ N $ R}
<Li> {if $ type [$ R [typeid] [name]} <span style = "color: # cc6600 "> [{$ type [$ R [typeid] [name]}] </span> {/if} <a href =" {$ R ['url' ]} "{title_style ($ R [style])} title = "{$ R ['title']}" target = "_ blank"> {str_cut ($ R [title], 33 ,'')} </a> </LI>
{/Loop}
{/PC}
10. Specify variable circular growth (often used in slides)
{PC: Content action = "Lists" catid = "66" Order = "listorder DESC" Thumb = "1" num = "5 "}
{PHP $ num = 0}
{Loop $ data $ R}
Linkarr [{$ num}] = "{$ R [url]}";
Picarr [{$ num}] = "{$ R [thumb]}";
Textarr [{$ num}] = "{str_cut ($ R [title], 36 ,'')}";
{PHP $ num ++}
{/Loop}
{/PC}
11. The article calls limit
{PC: Content action = "position" posid = "36" num = "1" Order = "listorder DESC limit 1, 1 --"}
Others are used as before
{PC: Content action = "position" posid = "31" Order = "listorder DESC" Limit = '1, 8 --'}
{Loop $ data $ R}
<Li> <a href = "{$ R [url]}" Title = "{$ R [title]}" target = _ blank> {str_cut ($ R [title], 36, '')} </a> </LI>
{/Loop}
{/PC}
12. The document starts calling at the specified position.
The starting position is 5, and 3 are called. It is equivalent to the limit function.
{PC: Content action = "position" posid = "27" Order = "listorder DESC" num = "3" Start = "5 "}
{Loop $ data $ R}
<A href = '{$ R [url]}'> {str_cut ($ R [description], 115)}... </a>
{/Loop}
{/PC}
13. Keyword called on the document list page or keyword called on the homepage
Note: explode (',', $ R [Keywords]) is to separate the keyword of an article by a comma, that is, each article must be separated by a comma, otherwise, all the calls will be called as a keyword. If it is a space interval keyword, change explode (',', $ R [Keywords]); to explode ('', $ R [Keywords]);
{PC: Content action = "Lists" catid = "$ catid" num = "10" Order = "id DESC" page = "$ page "}
{Loop $ data $ R}
<A href = "{$ R [url]}" >{$ R [title]} </a>
{PHP $ KEYWORDS = explode (',', $ R [Keywords]);}
<B> Article Tag: </B>
{Loop $ keywords $ keyword}
<A href = "{app_path} index. php? M = content & C = tag & catid = {$ catid} & tag = {urlencode ($ keyword)} "class =" blue ">{$ keyword} </a>
{/Loop}
{/Loop}
{/PC}
14. Some symbols appear every time there are several lines in the list (for example, the article recommendation in the home page shows two lines in one line, and you want to add a vertical line between the two lines | this code is used)
If the number is large, it is prone to errors because of the modulo operation ~~ Well, there are generally four titles below.
{PC: Content action = "position" posid = "8" Order = "listorder DESC" num = "2 "}
{Loop $ data $ R}
<A style = "color: #040605 "Title =" {$ R [title]} "href =" {$ R [url]} "target = _ blank> {str_cut ($ R [title], 26, '')} </a> {if $ n % 2 = 1} | {/if}
{/Loop}
{/PC}
15. The V9 list page perfectly supports custom segment calls
{PC: Content action = "Lists" catid = "$ catid" num = "25" Order = "id DESC" page = "$ page" moreinfo = "1 "}
{Loop $ data $ R}
<A href = "{$ R [url]}"> [{$ R ['field name']}]> {$ R [title]} </a>
{/Loop}
<Div class = "pagebar" >{$ pages} </div>
{/PC}
16. The current topic calls the parent and the following topic information methods
Other code should be regarded as a matter of course. This is a factor
{PHP $ arrchildid = $ categorys [$ cat [parentid] [arrchildid]}
{PC: Get SQL = "select * From v9_news where catid in ($ arrchildid) cache =" 3600 "page =" $ page "num =" 12 "return =" data "}
17. How to return the current page after the V9 form function is submitted, instead of the default homepage file address
Find the phpcms \ modules \ formguide \ index. php file line 73rd.
Showmessage (L ('thank'), app_path );
Modify the Code as follows to automatically return to the previous page.
Showmessage (L ('thank'), http_referer );
18. V9 homepage or paging Custom field call
Similar to 15
The first common list or topic calls custom Fields
Add the sub-Table moreinfo = 1 after {PC: Content action = "Lists" (1 is displayed, 0 is not displayed)
Example:
{PC: Content action = "Lists" moreinfo = 1 catid = "2" Order = "id DESC" num = "4 "}
<Ul>
{Loop $ data $ key $ Val}
<Li> <a href = "{$ Val ['url']}" >{$ Val ['title']} </a>
<Br> price: {str_cut ($ V ['custom Block'], 100)} // 100 words
</LI>
{/Loop}
</Ul>
{/PC}
Second, the recommendation bit calls the Custom Field
After adding a custom field to the model, you must click "yes" to "call in the recommendation space tag".
Then you can adjust the data in the same way. Remember, if you add an article, you must update the article before it is displayed. The custom segment is displayed only after you select it in the recommendation, select the add-on document to be added. Update the document to display it.
Example:
{PC: Content action = "position" posid = "Recommended bit ID" num = "30" Thumb = "1" moreinfo = "1" Order = "listorder DESC "}
{Loop $ data $ key $ Val}
<Li> <a href = "{$ Val ['url']}" target = "_ blank"> </a>
<A href = "{$ Val ['url']}" target = "_ blank"> {str_cut ($ Val ['title'], 20 )} </a> </LI>
{/Loop}
{/PC}
20. The Editor automatically uses the title as the alt parameter to upload images.
I. Modify statics/JS/ckeditor/plugins/image/dialogs/image. js
Find
Accesskey: 'T', 'default ':''
Replace
Accesskey: 'T', 'default': $ ('# title'). Val ()
Ii. Clear browser cache
21. Add random clicks of articles
Find $ views = $ R ['view'] + 1 in Row 3.
To:
$ Rand_nums = rand (79,186 );
$ Views = $ R ['view'] + $ rand_nums;
Indicates that the number of clicks increases by 79 to 186.
-------------------------------------------------------------
TIPS: a private solution to errors in some versions
1. thumbnails and gallery cannot be uploaded
\ Phpcms \ libs \ Classes \ attachment. Class. php
Put 24 rows (or 23 rows)
$ This-> upload_func = 'copy ';
Change
$ This-> upload_func = 'move _ uploaded_file ';
2. The fragment module cannot find the topic in the search article.
Phpcms \ modules \ block \ Templates \ search_content.tpl.php
Change 13 rows
<TD> <? PHP
If (isset ($ _ Get ['dosubmit ']) {?> <Div class = "RT"> <
Href = "javascript: void (0)" onclick = "$ ('# search'). Toggle ()"> <? PHP
Echo L ('folded _ up_in_search_of ')?> </A> </div> <? PHP}
Echo form: select_category ('', $ catid, 'name =" catid "id =" catid "','',
'', '0', 1)?> </TD>
22. Call the get tag of phpcms V9
1. Call a single piece of data in the system. For example, if the call ID is 1, the title cannot exceed 25 Chinese characters and the updated date is displayed ):
{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 multiple data entries in the system. For example, the call topic ID is 10 pieces of information that have passed the review. The title length cannot exceed 25 Chinese characters and the update date is displayed ):
{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. pagination. For example, (the ID of the calling topic is 10 pieces of information that have passed the review. The title cannot exceed 25 Chinese characters, and the updated date is displayed, with pagination ):
{Get SQL = "select * From phpcms_content where catid = 1 and status = 99 order by updatetime DESC" rows = "10" page = "$ page "}
Title: {str_cut ($ R [title], 50)} URL: {$ R [url]} update date: {date ('Y-m-d ', $ R [updatetime])}
{/Get}
Pagination: {$ pages}
4. Custom return variables. For example, the ID of the call topic is 10 pieces of information that have passed the review. The title length cannot exceed 25 Chinese characters, and the update date is displayed. The returned variable is $ v ):
{Get SQL = "select * From phpcms_content where catid = 1 and status = 99 order by updatetime DESC" rows = "10" return = "v "}
Title: {str_cut ($ V [title], 50)} URL: {$ V [url]} update date: {date ('Y-m-d ', $ V [updatetime])}
{/Get}
5. Call other databases under the same account. For example, (the 10 latest topics with the called database BBS and classification Id 1 have no more than 25 Chinese characters and the update date is displayed ):
{Get dbname = "BBS" SQL = "select * From cdb_threads where FID = 1 order by Dateline DESC" rows = "10 "}
Theme: {str_cut ($ R [subject], 50)} URL: http://bbs.phpcms.cn/viewthread.php? Tid = {$ R [TID]} update date: {date ('Y-m-d', $ R [Dateline])}
{/Get}
6. Call external data. For example, (the call data source is BBS, 10 latest topics with a category ID of 1, the topic length cannot exceed 25 Chinese characters, and the update date is displayed ):
{Get dbsource = "BBS" SQL = "select * From cdb_threads where FID = 1 order by Dateline DESC" rows = "10 "}
Theme: {str_cut ($ R [subject], 50)} URL: http://bbs.phpcms.cn/viewthread.php? Tid = {$ R [TID]} update date: {date ('Y-m-d', $ R [Dateline])}
{/Get}
Do you know if any of these methods cannot meet your needs?
For example, if you want to retrieve a maximum of 3rd to 10th comments, some people say that I do this. Generally, there is no reason to choose the first and second comments, because the thumbnail of phpcms is better for the size of and the scaling effect on the Long Bar (such as) is not good, In order to manually update the first and second records with the most comments, therefore, you do not want to automatically update and read the first two items.
<Ul>
<! -- {Get SQL = "SELECT. contentid,. catid,. title,. thumb,. description,. URL,. status,. updatetime, B. contentid, B. hits, B. comments from 'phpcms _ content' as a inner join 'phpcms _ content_count 'as B on. contentid = B. contentid and. status = 99 and length (. thumb)> 0
Order by B. Comments DESC limit 3, 7 "} -->
<Li> <SPAN class = "xxnse_fen2"> {$ R [comments]} comments </span> · <a href = "{$ R [url]}" title = "{$ R [title]}"> {str_cut ($ R [title], 28) }</A> </LI>
<! -- {/Get} -->
</Ul>
The key point is order by B. comments DESC limit 3, 7 (indicating reading 7 data records from 3rd records) is often used in MySQL. I tried it and the result is OK.
The effect is as follows:
I hope my phpcms developers can learn and share them together.
Phpcms V9 retains the 2008 get tag usage
It includes two methods: Internal data and external data.
First, let's analyze how to use internal data.
1. Call internal data
{PC: get SQL = "select * From 'xx' where FID = $ ltid and digest = 2 and ifupload = 1 order by TID DESC" num = "2" cache = "3600" return = ""data "}
{Loop $ data $ R}
.....
{/Loop} {/PC}
It can be seen that the get Statement supports the use of num, but does not support the use of limit 5, 5.
Sorry.
Num is the number of calls.
2. Call external data
{PC: Get SQL = "select * From phpcms_member" cache = "3600" page = "$ page" dbsource = "discuz" return = "data "}
<Ul>
{Loop $ data $ key $ Val}
{$ Val [username]} <br/>
{/Loop}
</Ul>
{$ Pages}
{/PC}
One is the data source, and the other is the pages paging effect.