[@cms_guestbook_list]标签详细介绍

标签介绍

参数:
siteId: 站点ID
ctgId: 类别ID,用于调用不同类别
checked: 是否审核后显示。0:不审核; 1:审核; 默认是不审核

作用:留言列表标签,显示用户的留言列表,不分页

具体例子

1
2
3
4
5
6
7
8
9
10
11
12
< div class = "blue_right_top mt5" > < h2 > < a href = "${base}/guestbook.jspx" target = "_blank" >网友留言 < / a > < / h2 > < / div >
< div class = "blue_right_div" style = "height:280px;" >
         < div class = "w96" >
[ @ cms_guestbook_list count = '10' ]
[ #list tag_list as m]
         < dl class = "gb" >
         < dt > < span > [ $ { m . ctg . name ! } ] < / span > $ { m . titleHtml ! } < / dt >
         < dd > $ { m . contentHtml ! } < / dd >
         < / dl >
[ / #list]          
[ / @ cms_guestbook_list ]     
< / div >

标签实现类

CmsGuestbookListDirective.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com . jeecms . cms . action . directive ;
 
import static com . jeecms . cms . Constants . TPL_STYLE_LIST ;
import static com . jeecms . cms . Constants . TPL_SUFFIX ;
import static com . jeecms . cms . web . FrontUtils . PARAM_STYLE_LIST ;
import static com . jeecms . common . web . Constants . UTF8 ;
import static com . jeecms . common . web . freemarker . DirectiveUtils . OUT_LIST ;
import static freemarker . template . ObjectWrapper . DEFAULT_WRAPPER ;
 
import java . io . IOException ;
import java . util . HashMap ;
import java . util . List ;
import java . util . Map ;
 
import org . apache . commons . lang . StringUtils ;
 
import com . jeecms . cms . action . directive . abs . AbstractCmsGuestbookDirective ;
import com . jeecms . cms . entity . assist . CmsGuestbook ;
import com . jeecms . cms . entity . main . CmsSite ;
import com . jeecms . cms . web . FrontUtils ;
import com . jeecms . common . web . freemarker . DirectiveUtils ;
import com . jeecms . common . web . freemarker . ParamsRequiredException ;
import com . jeecms . common . web . freemarker . DirectiveUtils . InvokeType ;
 
import freemarker . core . Environment ;
import freemarker . template . TemplateDirectiveBody ;
import freemarker . template . TemplateException ;
import freemarker . template . TemplateModel ;
 
/**
* 评论列表标签
*/
public class CmsGuestbookListDirective extends AbstractCmsGuestbookDirective {
     /**
     * 模板名称
     */
     public static final String TPL_NAME = "guestbook_list" ;
 
     /**
     * 输入参数,内容ID。
     */
     public static final String PARAM_SITE_ID = "siteId" ;
 
     @ SuppressWarnings ( "unchecked" )
     public void execute ( Environment env , Map params , TemplateModel [ ] loopVars ,
             TemplateDirectiveBody body ) throws TemplateException , IOException {
         CmsSite site = FrontUtils . getSite ( env ) ;
         int first = FrontUtils . getFirst ( params ) ;
         int max = FrontUtils . getCount ( params ) ;
         List < CmsGuestbook > list = cmsGuestbookMng . getList ( getSiteId ( params ) ,
                 getCtgId ( params ) , getRecommend ( params ) , getChecked ( params ) ,
                 getDesc ( params ) , true , first , max ) ;
 
         Map < String , TemplateModel > paramWrap = new HashMap < String , TemplateModel > (
                 params ) ;
         paramWrap . put ( OUT_LIST , DEFAULT_WRAPPER . wrap ( list ) ) ;
         Map < String , TemplateModel > origMap = DirectiveUtils
                 . addParamsToVariable ( env , paramWrap ) ;
         InvokeType type = DirectiveUtils . getInvokeType ( params ) ;
         String listStyle = DirectiveUtils . getString ( PARAM_STYLE_LIST , params ) ;
         if ( InvokeType . sysDefined == type ) {
             if ( StringUtils . isBlank ( listStyle ) ) {
                 throw new ParamsRequiredException ( PARAM_STYLE_LIST ) ;
             }
             env . include ( TPL_STYLE_LIST + listStyle + TPL_SUFFIX , UTF8 , true ) ;
         } else if ( InvokeType . userDefined == type ) {
             if ( StringUtils . isBlank ( listStyle ) ) {
                 throw new ParamsRequiredException ( PARAM_STYLE_LIST ) ;
             }
             FrontUtils . includeTpl ( TPL_STYLE_LIST , site , env ) ;
         } else if ( InvokeType . custom == type ) {
             FrontUtils . includeTpl ( TPL_NAME , site , params , env ) ;
         } else if ( InvokeType . body == type ) {
             body . render ( env . getOut ( ) ) ;
         } else {
             throw new RuntimeException ( "invoke type not handled: " + type ) ;
         }
         DirectiveUtils . removeParamsFromVariable ( env , paramWrap , origMap ) ;
     }
}
转载请注明: JEECMS主题站  »  [@cms_guestbook_list]标签详细介绍

你可能感兴趣的:(cms,jeecms)