Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the jspXCMS template file?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this article Xiaobian for you to introduce in detail "what is the jspXCMS template file", the content is detailed, the steps are clear, the details are handled properly, I hope this "jspXCMS template file is what" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

Template catalogue

Rules for saving the path of the template: / template/ {site ID} / {template theme}. If the current site ID is 1 and the template theme is default, the template path is / template/1/default. The home page template is usually / template/1/default/index.html.

It is important to note that although the template is also a HTML suffix, it is not exactly the same as a pure static HTML. For example, visit the home page http://localhost:8080/ in the browser to display the contents of the / template/1/default/index.html template. But as you all know, this address should visit the / index.html page. This is because the jspxcms system processes the home page request and forwards the request to the / template/1/default/index.html template. In other words, if you create a new file / template/1/default/test.html, you cannot access it through http://localhost:8080/test.html. Obviously, http://localhost:8080/test.html accesses / test.html instead of / template/1/default/test.html.

Similarly, if you access http://localhost:8080/template/1/default/index.html directly, the pure html content will be displayed directly, and the tags that get dynamic data will not be parsed.

Which requests will be processed by the jspxcms system and display the contents of the template? There are generally home pages (such as http://localhost:8080/), column pages (such as http://localhost:8080/node/12), detail pages, such as http://localhost:8080/info/8), etc.).

Template resources

Resource files such as css, js and images used to make templates must be placed in the {template path} / _ files directory, such as / template/1/default/_files. This is mandatory, otherwise the resource file will not be displayed correctly. To reference these resource files in the template, you can use relative paths, such as: _ files/my.jpg, _ files/img/my.png, _ files/css/my.css, _ files/scripts/my.js.

Why does it have to be in the _ files directory, and why is there this restriction? In fact, this is not a limitation, but a convenience provided by the system. For example, to quote / template/1/default/img/my.jpg pictures in / template/1/default/index.html, write directly.

There seems to be no problem in the static page; but in actual operation, the access address of the home page is http://localhost:8080/, so the corresponding image should be / img/my.jpg, which obviously cannot be accessed. It should be written

To access the picture. Writing such a long address is very troublesome and inflexible. So the system provides a convenience to replace _ files with / template/1/default/_files at run time, such as

The actual runtime will be replaced with

.

So there are two ways to reference the corresponding resources, one is to write the full address, such as

So that the resource files can be placed wherever they want, as long as the address is correct; the second way is to place the resource path in the _ files directory, reference the resource through a path like _ files/css/my.css, and the system will automatically replace it with / template/1/default/_files/css/my.css at run time.

Template file

Template files are divided into system templates and custom templates. The file name of the system template is fixed and cannot be modified; the file name of the custom template can be defined by itself, even in Chinese (pay attention to setting the correct encoding in the Linux system).

The system template starts with sys_, which mainly includes member center template, message board template, comment template, voting template, questionnaire template, RSS template, special cover list template, search page template and so on. These templates correspond to url addresses, such as:

Search page. Url:/search (e.g. http://www.mysite.com/search), template: sys_search.html (e.g. / template/1/default/sys_search.html)

Message Board. Url:/guestbook (e.g. http://www.mysite.com/guestbook), template: sys_guestbook.html (e.g. / template/1/default/sys_guestbook.html)

Custom templates mainly include home page template, column page template, detail page template, special detail page template and so on. In addition, there are some special advertising templates (templates under the sys_ad directory) and app templates (templates at the beginning of app_).

Template and URL address

The user's URL request is first processed by the program, and then the program parses the template and returns the result. If you access the template directly, it will be displayed as a static HTML, and the FreeMarker code and Jspxcms tags will not be parsed.

URL addresses are preset by the program, such as column page address / node/ {column ID} .jspx, detail page address / info/ {document ID} .jspx, search page address / search.jspx, RSS address / rss.jspx. Column pages and detail pages support static, and if page static is used, the URL address depends on the settings for page static, such as / news/, / news/index.html, / news/23.html.

The URL address of the column page and the URL address of the detail page can be obtained through the properties of the object, such as ${node.url}, ${info.url}; do not write a fixed URL, such as / node/12.jspx, / info/89.jspx, which will not automatically switch to the static page address when using the static page.

Universal default objects for templates

Global: global object. Type: com.jspxcms.core.domain.Global.

Site: current site. Type: com.jspxcms.core.domain.Site.

Orgs: the collection of organizations to which the current user belongs (a user can belong to multiple organizations). Null if you are not logged in. Type: java.util.Collection.

Org: the main organization to which the current user belongs. Null if you are not logged in. Type: com.jspxcms.core.domain.Org.

Groups: the collection of user groups to which the current user belongs (a user can belong to multiple user groups). If you are not logged in, it is a tourist user group. Type: java.util.Collection.

Group: the primary user group to which the current user belongs. If you are not logged in, it is a tourist user group. Type: com.jspxcms.core.domain.MemberGroup.

User: currently logged in user. Null if you are not logged in. Type: com.jspxcms.core.domain.User.

Dy: dynamic path. For example, the search page address ${dy} / search.jspx.

Ctx: context path. For example: ${ctx} / static/vendor/My97DatePicker/WdatePicker.js. Is equivalent to HttpServletRequest.getContextPath (). Type: java.lang.String.

Url: the URL address of the current page. Type: java.lang.String.

Read here, this "what is the jspXCMS template document" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report