Get tag call article

Source: Internet
Author: User
1. Call a single piece of data in the system. For example, (the call ID is 1. The title cannot exceed 25 Chinese characters and the updated date is displayed.): {getsqlselect * fromphpcms_contentwherecontent} title: {str_cut ($ r [title], 50)} URL: {$ r [url]} update date: {date (Y-m-d, $ r [updatetime])} abstract

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])} Abstract


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])}

Summary: $ r [description]


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}



@ 7-day click ranking


    {Get SQL = "SELECT * FROM 'phpcms _ content' c, 'phpcms _ content_count 'n WHERE updatetime> '. TIME. '-7*86400 and c. contentid = n. contentid AND c. 'status' = 99 and catid = '$ catid ''. get_ SQL _catid ($ catid ). 'order BY n. hits DESC "rows =" 8 "}
  1. {Str_cut ($ r [title], 88 )}

  2. {/Get}

@ Comment ranking within 7 days


    {Get SQL = "SELECT * FROM 'phpcms _ content' c, 'phpcms _ content_count 'n WHERE updatetime> '. TIME. '-7*86400 and c. contentid = n. contentid AND c. 'status' = 99 and catid = '$ catid ''. get_ SQL _catid ($ catid ). 'order BY n. comments DESC "rows =" 8 "}
  1. {Str_cut ($ r [title], 88 )}

  2. {/Get}


{Get SQL = "SELECT * FROM 'phpcms _ content' a, 'phpcms _ c_news 'B WHERE a. contentid = B. contentid AND 'status' = 99 AND 'thumb '! = ''AND. 'contentid' IN (SELECT 'contentid' FROM 'phpcms _ content_position 'where 'posid '= '10 ')". get_ SQL _catid ($ catid ). "order by. contentid DESC "rows =" 3 "}



{If $ r [style]} {str_cut ($ r [title], 800, '')} {else} {str_cut ($ r [title], 800, '')} {/if}


{/Get}



    {Get SQL = "SELECT * FROM phpcms_content c, phpcms_digg d WHERE c. contentid = d. contentid AND c. status = 99 ORDER BY d. supports DESC" rows = "8 "}
  1. {$ R [supports]} {str_cut ($ r [title], 88 )}

  2. {/Get}

@ Only news with the news model and ID 7 recommended


    {Get SQL = "SELECT * FROM phpcms_content c, phpcms_c_news n, phpcms_content_position p WHERE c. contentid = n. contentid and c. contentid = p. contentid and posid = 7 and 'status' = 99 order by inputtime DESC "rows =" 6 "}
  • {Str_cut ($ r [title], 88 )}

  • {/If}

@ Call related news
{Get SQL = "SELECT * FROM phpcms_content c, phpcms_content_tag t WHERE c. contentid! = '$ Contentid' and c. contentid = t. contentid and c. status = 99 AND t. tag IN ('. get_ SQL _in ($ r [keywords]). ') order by c. contentid DESC "rows =" 6 "}

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

  • {/Get}


    Compared with other CMS, phpcms is more professional and powerful. However, the requirements for webmasters are slightly higher. Especially for webmasters with poor foundations, many of them are confused. I personally contacted PHPCMS2008 for more than two weeks. After reading several tutorials on the Forum, I decided to write my own experiences in the use process so that the majority of new Webmasters can easily get started and build their own websites. [Premise statement: the personal level is limited. If there are any deficiencies or errors, I hope you can give me more advice .]






    2. Common get call Methods
    I think this method is flexible. Personal Recommendation. Next, we will focus on several common get call methods. I personally think it is enough to make a PHPCMS template and understand get.
    (1) Call the latest articles with thumbnails under a topic, and call the content description (multiple topic IDs)


    {Get SQL = "select * from phpcms_content where catid> = 79 and catid <= 85 and status = 99 and posids = 1 and 'thumb '! = ''Order by updatetime desc "rows =" 1 "}

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




  • {Str_cut ($ r [description], 100 )}


    {/Get}


    Note: phpcms_content is the name of the data table in the database. If your data table prefix is modified, it must be modified here. If you set it to woshi _ when installing phpcms, it should be woshi_content.
    Catid> = 79 and catid <= 85 topic ID is greater than or equal to 75 and topic id is less than or equal to 85. That is to call the topic ID75 76 77 78 79 80 81 82 83 84 85 Article.
    Posids = 1 recommended for Homepage
    Status = 99 Article approved
    'Thumb '! = ''The thumbnail is not empty, that is, you must have a thumbnail.
    Url of the {$ r [url]} content page
    {Str_cut ($ r [title], 40)} article title, with a length limit of 40
    {Thumb ($ r [thumb], 110, 75)} The thumbnail size of the thumbnail address is limited to width = 110px height = 75px.
    {Str_cut ($ r [description], 100) Introduction to call 100


    Through the above call and template Statement (p li margin, I can get test.gif through csscontrol. The specific css section will be discussed later.
    (2) call multiple column IDs. (The column ID is a discontinuous ID.) That is to say, at the initial stage of the Column Establishment, there is a column ID75 76 77 78 79 80 81 82 83 84 85. After other columns are created, a new column is added in this column to generate a new ID. For example, ID 95. How should we use get to call it?
    In (1), we use catid> = XX and catid <= XX. If we want to add catid95, we cannot use and instead use or. The procedure is as follows:
    {Get SQL = "select * from phpcms_content where catid> = 79 and catid <= 85 or catid = 95 order by updatetime desc" rows = "6 "}
    {/Get}
    If we call the Article Title List number of 6 here, then we need to loop in p should be li. The details are as follows:


    {Get SQL = "select * from phpcms_content where catid> = 79 and catid <= 85 or catid = 95 order by updatetime desc" rows = "6 "}

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

  • {/Get}


    The updatetime sorting method is described here. For example, we want to sort the articles in descending order (that is, before the latest row) according to the time entered in the article. After updatetime is used, we will find that after the previous article is edited, this article is called at the beginning of the list. Therefore, updatetime is the time when the document is edited or modified. If we do not want to sort the document in this way, we want to sort it in descending order by the time entered in the article. Can we change updatetime here to inputtime?


    (3) Use get to call the topic name and its corresponding topic address
    When using get SQL queries, we usually query the phpcms_content table, which contains all the articles, downloads, and other content information, but the column only has the id but no column name, all the topic information is in the phpcms_category table. In fact, when we open the database, we can see it at a glance. Therefore, when calling the column name and its address, we need to use {str_cut ($ CATEGORY [$ r [catid] [catname], 4)} to transmit parameters, I simply added the length of the topic name for your convenience. Haha. If there is sufficient BT, the specific example is as follows:


    {Get SQL = "select * from phpcms_content where catid> = 52 and catid <= 55 or catid = 50 or catid = 77 or catid = 78 order by updatetime desc" rows = "6 "}

  • [{Str_cut ($ CATEGORY [$ r [catid] [catname], 4)}]

    {Str_cut ($ r [title], 38 )}

  • {/Get}


    The topic ID of this get call is 52 53 54 55 77 78 active and active!
    {$ CATEGORY [$ r [catid] [url]} topic address
    {Str_cut ($ CATEGORY [$ r [catid] [catname], 4)} the length of the topic name is 4. Adjust it as needed ~


    (4) How do I call the title Color Set in the background ???
    In fact, this stuff is not mysterious at all. It's just! The following is an example!



      {Get SQL = "select * from 99inet_content where catid = 40 and status = 99 order by updatetime desc" rows = "7 "}
    • [{Date ('m-d', $ r [updatetime])}] {if $ r [style]} {str_cut ($ r [title], 22 )} {else} {str_cut ($ r [title], 22)} {/if}

    • {/Get}


    I won't talk about the {get} part. I basically mentioned it above ~ [{Date ('m-d', $ r [updatetime ])}]
    In this small part, you should pay attention to the Blue Code marked by me and the green code. Someone may ask: Why do I call the title twice ?? Don't rush to tell you why.
    {If $ r [style]} {str_cut ($ r [title], 22)} {else} {str_cut ($ r [title], 22)} {/if}
    In fact, this code is easy to understand. {If $ r [style]} if the style field of the document corresponding to the database is not empty (that is, there is content), {str_cut ($ r [title], 22)}. That is to say, if you set the title Color or effect (bold or italic) in this article, the final html page should be like this.
    In fact, the website title class is officially set. Here B is the title bold. We will not go into the value here.
    If the title is not added to the background. The html you generated is
    No call
    I try to make it simple. I think it should be very simple. Haha

    I forgot a bit, but I remember a new guy who seems to have sent it before. I want to add it as well. In this way, the general usage of get is quite comprehensive.
    (5) call tips: limit parameter. [For example, the number of consecutive messages starting from the second call]



      {Get SQL = "select * from phpcms_content where catid = 39 and status = 99 order by updatetime desc limit 2, 7 "}
    • [{Date ('m-d', $ r [updatetime])}] {if $ r [style]} {str_cut ($ r [title], 22 )} {else} {str_cut ($ r [title], 22)} {/if}

    • {/Get}


    For the articles whose topic id is 39 and has passed the review, there are seven consecutive messages starting from the second one. The title Color Set in the call background described above is used.
    Simple and simple. This is the end. By the way, row cannot be used at the same time when limit is used. Why? You can understand it.

    (6) How to Use get to call all Article model articles on the topic homepage (this is the entire Model)


    {Get SQL = "SELECT contentid, catid, typeid, areaid, title, style, thumb, keywords, description, userid, updatetime, inputtime, url FROM 'imi _ content' WHERE status = 99 ". get_ SQL _catid ($ cid ). "order by contentid DESC" rows = "40 "}

  • {$ R [title]}

  • {/Get}


    It's a pity that all of the models can be tested to give a thought...

    (7) recently I found a problem, that is, the value of id, which is confusing during get usage, so today I added a description for calling the content of all subtopics on the topic homepage. At the same time, we also mention another method for assigning values to IDs.

    {Get SQL = "SELECT * FROM 'phpcms _ content' c, 'phpcms _ content_count 'n WHERE c. contentid = n. contentid AND c. 'status' = 99 and catid in (39,40, 41,42, 43,44, 45,46, 47,48, 66,68, 69,70, 71,72, 73,74, 75,76) order by contentid DESC "rows =" 10 "}

  • {$ R [title]}

  • {/Get}
    Which method can be used depends on your preferences. I personally think that the goal can be achieved.

    Note that the 'phpcms _ content' symbol in (6) and (7) is ''rather than''. If it is wrong, it cannot be executed.

    Editor's note: In fact, many people say that you are using get. I don't know or don't understand it. In fact, I think most of the situations encountered in get usage have been listed. If you are willing to take a moment to look at and study, I don't think it is very difficult. Because it is really very simple ....
    This tutorial has come to an end for the moment, followed by the p + css section!

    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.