Usually you can call forum posts using the forum’s calling post JS, but today we are going to explain how to use tags to call forum posts in the Empire CMS template production, because tags are more flexible.
Note: discuz here supports X3.1, and the test on the homepage of the webmaster zone is correct. The webmaster zone uses method 2, which is the
method 1 of smart tag call:
The forum data call is realized through the combination of ecmsinfo tag and SQL call.
Usage points:
1. Use the ecmsinfo tag; (Click here to view the ecmsinfo tag usage tutorial)
Tag syntax: [ecmsinfo] column ID, number of items displayed, Number of title interceptions, whether to display the column name, operation type, template ID, and only display pictures with titles [/ecmsinfo]
2. Use the "query by sql" operation type in the tag;
tag The "column ID" in the parameters is a SQL statement; the "operation type" is "24".
3. Make a display style template
Use "[!--title--]" in the tag template to indicate the post title; "[!--id--]" indicates the post ID.
Tag syntax example:
[ecmsinfo]'select post title field as title, post ID field as id from post data table order by sort field desc limit number of calls', 0, number of words for title interception, 0, 24, template ID, 0[/ecmsinfo]
For example: (call the latest 10 posts in the forum)
DISCUZ forum: [ecmsinfo]'select subject as title,tid as id from pre_forum_thread order by tid desc limit 10',0,30,0,24,1,0[/ecmsinfo]
PHPWIND Forum:[ecmsinfo]'select subject as title,tid as id from pw_threads order by tid desc limit 10',0,30,0,24,1,0[/ecmsinfo]
(Note: If the forum and the empire CMS are installed in different databases, "post Data table" is represented by "database.data table", such as "discuzdb.cdb_threads".)
·Example: calling DISCUZ forum post
Calling DISCUZ forum post tag syntax:
[ecmsinfo]'select subject as title,tid as id from pre_forum_thread order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]
Call post The number of subtitles is 10; the number of intercepted post titles is 30 characters; use the template with tag template ID=7. (Note: If you change the database prefix, please make corresponding changes.)
Create a display style template:
Log in to the backend->"Template Management"->"Add Label Template" , add two label templates, "Display one row and one column" and "Display multiple columns in one row".
After the addition is completed, return to the "Tag Template" management and you will see the two tags we just added. (www.zzarea.com website construction)
Now we modify the homepage template:
Log in to the backend->"Template Management"->"Public Template"->"Modify the homepage template ", copy the template content to Dreamweaver for editing, and add a label for calling forum posts in the template, as shown below:
(Note: "where fid=section ID" means calling posts by forum section.)
After modifying the homepage template, copy the template code content to the background homepage template text box, and then click Modify.
After modifying the homepage template, we click "Preview" to view the modified homepage effect. Hey, have all the forum posts been moved to the Empire CMS?
Other instructions: The SQL statement in the example above is to call new posts in forums and sections. You can also call popular posts, highlight posts, etc., just change the sorting and conditions of the SQL statement. There are more applications, such as calling relevant forum posts in the information page, calling other system data, etc.
Method 2: Use the smart tag [e: loop] to call the forum post
Call the latest post of Discuz: pre_ is the table prefix of discuz
<table width="100%" border="0" cellspacing="1" cellpadding="3"> [e:loop={"select tid,subject from pre_forum_thread order by tid desc limit 10",10,24,0}] <tr><td> <a href="http://bbs.zzarea.com/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a> </td></tr> [/e:loop] </table>
Call the latest post of PHPwind Sub: pw_ is the table prefix of phpwind
<table width="100%" border="0" cellspacing="1" cellpadding="3"> [e:loop={"select tid,subject from pw_threads order by tid desc limit 10",10,24,0}] <tr><td> <a href="/bbs/read.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a> </td></tr> [/e:loop] </table>
The above is the detailed content of Empire Cms template production calling forum post tutorial. For more information, please follow other related articles on the PHP Chinese website!