Here is my own definition of the label mycontent_list
First, a jc_mycontent table is created in the database with Id,title,content three fields
Second, an entity class was created
... Get Set method
}
Next, configure the configuration file for the Jc_mycontent table in hibernate
Persistent layer interfaces for interacting with databases
Persistence layer Implementation Class
Business Layer Interface
Business Layer Implementation Class
The abstract class of the label class, the most important is getdata this method, as well as the binding business layer, which can add a variety of query methods. Refer to Class Abstractcontentdirective
The most important class in the custom label inherits the abstract class above
public class Mycontentlistdirective extends Abstractmycontentdirective {/** * template name */public static final String Tpl_na ME = "Mycontent_list"; @SuppressWarnings ("unchecked") public void execute (Environment env, MAP params, templatemodel[] loopvars, Templatedirectivebody body) throws Templateexception, IOException {//get site Cmssite sites = frontutils.getsite (env);//Get content Listing list<mycontent> list = GetList (params, env); map<string, templatemodel> paramwrap = new hashmap<string, templatemodel> (params); The Out_list value is tag_list, where the table of contents is placed Paramwrap.put (myout_list, Default_wrapper.wrap (list)); Copy the value of the params to variable map<string, templatemodel> origmap = directiveutils.addparamstovariable (env, Paramwrap ); Not using the default template, directly using their own written simple template (mycontent_list.html) frontutils.includetpl (tpl_name, site, params, env); Remove the params value from the variable directiveutils.removeparamsfromvariable (env, Paramwrap, Origmap); } protected list<mycontent> GetList (map<string, templatemodel> params, ENVIronment env) throws Templateexception {return mycontentmng.getlist ();}}
Style template mycontent_list.html content, inside can add some of their own style, can refer to \t\cms_sys_defined\style_list under the style file
Add the following code to the homepage.
[@cms_mycontent_list] <ul class= "Topnews" >
With these codes, you can query the data in your own table jc_mycontent and display it on the page
JEECMS Station Group Management System--the implementation process of customizing labels and using the tables you create