Phpcmsv9 template tag tips and common labels _ PHP Tutorial

Source: Internet
Author: User
Tags clear browser cache
Phpcmsv9 is a common method of tag. Phpcmsv9 template to create a set of common code 1. the length of the call title {str_cut ($ r [title], 36,)} is intercepted, and the quotation marks are used to remove .... 2. formatting time call formatting Time 2011-05-061 phpcms v9 template creation common code set

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}

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

  • {/Loop}
    {/Pc}
    4. display the topic name (only name, without link)

    {$ Catname}
    Show the topic name and link (you can click)

    {$ CATEGORYS [$ r ['catid'] ['catname']}
    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}
    {Str_cut ($ r [uname], 28 ,'')}
    {/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}
    {$ R [catname]} |
    {/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 "}

    {Loop $ data $ n $ r}

  • {If $ TYPE [$ r [typeid] [name]} [{$ TYPE [$ r [typeid] [name]}] {/if} {str_cut ($ r [title], 33 ,'')}

  • {/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}

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

  • {/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}
    {Str_cut ($ r [description], 115 )}...
    {/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}
    {$ R [title]}
    {Php $ keywords = explode (',', $ r [keywords]);}
    Article tag:
    {Loop $ keywords $ keyword}
    {$ Keyword}
    {/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}
    {Str_cut ($ r [title], 26, '')} {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}
    [{$ R ['Field name']}]> {$ r [title]}
    {/Loop}

    {$ Pages}


    {/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 "}


      {Loop $ data $ key $ val}
    • {$ Val ['title']}

      Price: {str_cut ($ v ['custom Block'], 100)} // 100 words

    • {/Loop}

    {/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}


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

  • {/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

    If (isset ($ _ GET ['dosubmit ']) {?>

    Href = "javascript: void (0)" onclick = "$ ('# Search'). toggle ()"> Echo L ('folded _ up_in_search_of ')?>

    Echo form: select_category ('', $ catid, 'Name =" catid "id =" catid "','',
    '', '0', 1)?>
    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.



    • {$ R [comments]} comments {str_cut ($ r [title], 28 )}


    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 "}

      {Loop $ data $ key $ val}

      {$ Val [username]} <br/>

      {/Loop}

      {$ Pages}

      {/Pc}

      One is the data source, and the other is the pages paging effect.

      Http://www.bkjia.com/PHPjc/477557.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477557.htmlTechArticlephpcms v9 template production common code set 1. the length of the call title {str_cut ($ r [title], 36,)} is intercepted, and the quotation marks are used to remove .... 2. formatting time call formatting time 1...

    Related Article

    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.