RS statement is used for reading datas of topic or ORACLE data from sql. All statements can be nested in RS statement
Note:Data such as BLOB、JAVA_OBJECT、LONGVARBINARY、VARBINARY、STRUCT、REF、DATALINK、LONGVARCHAR、OTHER、DISTINCT is not supported. All the data above will be skipped and return to NULL.
<rs id=(id:STRING) sql=(sql:STRING) topic=(topic:STRING) where=(where:STRING) orderby="orderby:STRING" from=(from:int) rows=(rows:int) page=(page:int) style=(style:STRING)>
--Input your text content here
</rs>
SQL and topic parameter must be placed after id parameter and before other parameters.
| parameters | type | meaning | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | STRING | Unique identification of the RS. It must begin with letters or underline. | ||||||||||||||||||||
| sql | STRING | The SQL query statement that needs to be executed. Optional, you must choose either “sql” or “topic”. You can also choose both. If the field appeared in context or JAVA character string need to be contained, you should use <%= and %> to closure. The following example illustrates how to inquire product’s sales status. <rs id="rs1" sql="select productid,productname from product"> <$rs1.productname$> <rs id="rs2" sql=<%="select customer from sales where productid='" + <$rs1.productid$> + "'"%>> <$rs2.customer$> </rs> </rs> |
||||||||||||||||||||
| topic | STRING | The topic code that need to be inquired.You can quote article tag
and attachment tag only with the ID number of the RS. Optional, if both SQL and topic are not assigned, then the system would calculate according to current context and pick the topic that current template belongs to. For custom data sources,It will retrive datas in the topic designated only; for non-custom data sources,It will retrive all datas in the topic designated and it's children. If topic assigned to empty string(""),It will retrive all datas of all non-custom data source in current site. i.e.: a topic named “news” would be: <rs id ="rs1" topic="news"> <$rs1.art_title$> </rs> |
||||||||||||||||||||
| where | string |
Optional,Additional WHERE clause for SQL,and must appear with the topic parameters together.
The statement will appeare in the following SQL statement in red marked with where_clause.
For topics sorted automatically: For non-custom data source,the SQL statement is as follows: select a.*,b.name uname,c.name deptname,d.name unitname from article a,users b,dept c,unit d,topic e where a.topic=e.id and b.dept=c.id and c.unit=d.id and a.creator=b.id and (e.code ='<$top_code$>' or e.code like '<$top_code$>.%') and a.state=3 and a.siteid='<$site_id$>' and (where_clause) order by orderby_statement For custom data source,the SQL statement is as follows: select b.*,a.title,a.siteid,a.topic,a.state,a.createdate,a.publishdate from <$custom_table$> b,<$custom_table$>_prop a where a.state=3 and b.id=a.id and a.topic='<$top_id$>' and (where_clause) order by orderby_statement For topics sorted manually: select a.* from article_sort a where a.state=3 and a.siteid='<$site_id$>' and a.topic='<$top_id$>' and (where_clause) order by orderby_statement |
||||||||||||||||||||
| orderby | string |
Optional.The ORDER BY clause allows you to sort the records in your result set. For topics sorted automatically: For non-custom data source,"a.important desc,a.publishdate desc" as default. For custom data source,"a.publishdate desc" as default. For topics sorted manually, "a.idx,a.publishdate desc" as default. |
||||||||||||||||||||
| from | int | Optional, reading data from the item of number X. As default, it will calculate from number 0. |
||||||||||||||||||||
| rows | int | Optional, reading total items of X, All the rest data will be read if it haven’t been filled. | ||||||||||||||||||||
| page | int | Optional, pagination. System will automatically page when the
item number was reached.
|
||||||||||||||||||||
| style | String |
Optional, pagination style. Default value is "modern". A sample css style file comes with NPS, you could find it at <$NPS_HOME$>/css/pagebreak.css, the easies way is to copy it to your website and customize it.
|
Please use JAVA statement to set all fields showed below before RS statement.
ATTENTION PLS:
1.please re-set all fields but not one of them only.
2.If you only want to customize your CSS style, please just do it with /css/pagebreak.css
3.Format String Syntax, please see java Formatter class for more detail:
The format specifiers for general, character, and numeric types have the following syntax:
%[argument_index$][flags][width][.precision]conversion
The optional argument_index is a decimal integer indicating the position of the argument in the argument list. The first argument is referenced by "1$", the second by "2$", etc.
The optional flags is a set of characters that modify the output format. The set of valid flags depends on the conversion.
The optional width is a non-negative decimal integer indicating the minimum number of characters to be written to the output.
The optional precision is a non-negative decimal integer usually used to restrict the number of characters. The specific behavior depends on the conversion.
The required conversion is a character indicating how the argument should be formatted. The set of valid conversions for a given argument depends on the argument's data type.
| Conversion | Argument Category | Description |
|---|---|---|
'b', 'B' |
general | If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(arg). Otherwise, the result is "true". |
'h', 'H' |
general | If the argument arg is null, then the result is "null". Otherwise, the result is obtained by invoking Integer.toHexString(arg.hashCode()). |
's', 'S' |
general | If the argument arg is null, then the result is "null". If arg implements Formattable, then arg.formatTo is invoked. Otherwise, the result is obtained by invoking arg.toString(). |
'c', 'C' |
character | The result is a Unicode character |
'd' |
integral | The result is formatted as a decimal integer |
'o' |
integral | The result is formatted as an octal integer |
'x', 'X' |
integral | The result is formatted as a hexadecimal integer |
'e', 'E' |
floating point | The result is formatted as a decimal number in computerized scientific notation |
'f' |
floating point | The result is formatted as a decimal number |
'g', 'G' |
floating point | The result is formatted using computerized scientific notation or decimal format, depending on the precision and the value after rounding. |
'a', 'A' |
floating point | The result is formatted as a hexadecimal floating-point number with a significand and an exponent |
't', 'T' |
date/time | Prefix for date and time conversion characters. See Date/Time Conversions. |
'%' |
percent | The result is a literal '%' ('\u0025') |
'n' |
line separator | The result is the platform-specific line separator |
| Symbol | Meaning | Value | Parameter(s) |
|---|---|---|---|
| PAGEBREAK_HEADER | page header | <div class='clear'></div><div class='pagebreak_modern'> | |
| PAGEBREAK_PREVPAGE | Previous Page | <span class='prevpage'><a href='%1$s'>Previous</a></span> | URL for previous |
| PAGEBREAK_NEXTPAGE | Next Page | <span class='nextpage'><a href='%1$s'>Next</a></span> | URL for next |
| PAGEBREAK_SKIP | Omit symbol | <span class='omit'>...</span> | |
| PAGEBREAK_PAGE | page number | <span class='page'><a href='%1$s'>%2$s</a></span> | URL,Page number |
| PAGEBREAK_CURRENTPAGE | Current page | <span class='currentpage'>%2$s</span> | URL,page number |
| PAGEBREAK_TOTAL | Summary Bar | <span class='total'>共%2$d页</span> | records, pages, records per page, current page number |
| PAGEBREAK_SELECTBOX | select box | <select class='page_select' onchange='javascript:window.location=this.value'> | |
| PAGEBREAK_FOOTER | page footer | </div> |
| Symbol | Meaning | Value | Parameter(s) |
|---|---|---|---|
| PAGEBREAK_HEADER | page header | <div class='clear'></div><div class='pagebreak_onebyone'> | |
| PAGEBREAK_PREVPAGE | Previous page | <span class='prevpage'><a href='%1$s'>上一页</a></span> | URL for previous page |
| PAGEBREAK_NEXTPAGE | Next page | <span class='nextpage'><a href='%1$s'>下一页</a></span> | URL for next page |
| PAGEBREAK_SKIP | Omit symbol | ||
| PAGEBREAK_PAGE | Page number | <span class='page'><a href='%1$s'>%2$s</a></span> | URL, page number |
| PAGEBREAK_CURRENTPAGE | Current page | <span class='currentpage'>%2$s</span> | URL, page number |
| PAGEBREAK_TOTAL | Summary bar | records, pages, records per page, current page number | |
| PAGEBREAK_SELECTBOX | select box | ||
| PAGEBREAK_FOOTER | page footer | </div> |
| Tag | Type | Meaning |
|---|---|---|
| rowno | int | current row no |
1.Tags begin with “<$”, and end with “$>”
2.The id of RS statement must be prefixed to tag,i.e.:<$rs1.productname$>.Note: ID’s case sensitivity should be in accordance with the definition. The afterwards variables are not case sensitive.
3.The Tag of “rowno” represents the row number of RS,It is integer,i.e.:<$rs1.rowno$>。
4.The RS statement which adopt “topic” parameter could use article tag. Note: for self-defined data source, only these artcile tags can be used: <$art_id$>、<$art_title$>、<$art_url$>、<$art_createdate$> and <$art_publishdate$>.
5.You can use ATTACH statement in the RS statement. Generally, the attachment tag doesn’t work (namely no any data.) unless the self-defined datasource is customized (e.g.: product management).
6.The RS statement which adopt "sql" parameter could use tags with the SQL name.
7.You can put parentheses right after parameter name in which you should put format parameter or limited condition on word amount.i.e.:<$rs1.productname(50)$>. For different types of data, it generally means:
1)String type:
<$rs1.productname(50)$> means to take 50 characters from front to back, one Chinese character accounts for one character.
<$rs1.productname(50,"...")$> means to take 50 characters from front to back.The characters more the 50 will be truncated,and "..." appended.
2)Decimal type:Below is the detailed instruction:
| Symbol | Location | Meaning |
|---|---|---|
0 |
Number | Digit |
# |
Number | Digit, zero shows as absent |
. |
Number | Decimal separator or monetary decimal separator |
- |
Number | Minus sign |
, |
Number | Grouping separator |
E |
Number | Separates mantissa and exponent in scientific notation. Need not be quoted in prefix or suffix. |
; |
Subpattern boundary | Separates positive and negative subpatterns |
% |
Prefix or suffix | Multiply by 100 and show as percentage |
\u2030 |
Prefix or suffix | Multiply by 1000 and show as per mille |
¤ (\u00A4) |
Prefix or suffix | Currency sign, replaced by currency symbol. If doubled, replaced by international currency symbol. If present in a pattern, the monetary decimal separator is used instead of the decimal separator. |
' |
Prefix or suffix | Used to quote special characters in a prefix or suffix, for example, "'#'#" formats 123 to "#123". To create a single quote itself, use two in a row: "# o''clock". |
|
Letter |
Date or Time Component |
Presentation |
Example |
|
G |
Era designator
|
Text |
AD |
|
y |
year |
Year |
1996; 96 |
|
M |
Month in year |
Month |
July; Jul; 07 |
|
w |
Week in year |
Number |
27 |
|
W |
Week in month |
Number |
2 |
|
D |
Day in year |
Number |
189 |
|
d |
Day in month |
Number |
10 |
|
F |
Day of week in month |
Number |
2 |
|
E |
Day in week |
Text |
Tuesday; Tue |
|
a |
Am/pm marker |
Text |
PM |
|
H |
Hour in day (0-23) |
Number |
0 |
|
k |
Hour in day (1-24) |
Number |
24 |
|
K |
Hour in am/pm (0-11) |
Number |
0 |
|
h |
Hour in am/pm (1-12) |
Number |
12 |
|
m |
Minute in hour |
Number |
30 |
|
s |
Second in minute |
Number |
55 |
|
S |
Millisecond |
Number |
978 |
|
z |
Time zone |
General time zone
|
Pacific Standard Time;
PST; GMT-08:00 |
|
Z |
Time zone |
RFC 822 time zone
|
-0800 |
Get all articles in current topic.
<rs id="rs1">
<$rs1.art_title$>
</rs>
Same as top.Get all articles in current topic.
<rs id="rs1" topic=<$top_code$>>
<$rs1.art_title$>
</rs>
Get all articles which importance is "very important", and order by publish date
<rs id="rs1" topic=<$top_code$> where="a.important=2" orderby="a.publishdate">
<$rs1.art_title$>
</rs>
Get top 20 articles in topic coded in "top1"
<rs id="rs1" topic="top1" rows=20>
<$rs1.art_title$>
</rs>
Get all articles in current topic,andin display pages by 20 pieces of articles per page
<rs id="rs1" page=20>
<$rs1.art_title$>
</rs>
Get top 20 rows from database
<rs id="rs1" sql="select productid,productname from product" rows=20>
<$rs1.productname$>
</rs>
Get products' list and get customer with each product.
<rs id="rs1" sql="select productid,productname from product">
<$rs1.productname$>
<rs id="rs2" sql=<%="select customer from
sales where productid=" + <$rs1.productid$>%>>
<$rs2.customer$>
</rs>
</rs>