Before creating your site, it is advised to read the documentation:Before beginning.
The block token reads and displays the entity allocated to the section by setup:
1. It reads the entity/ies from the X3 database by calling up an interface (Web service) of type 'Access to data',
2. It carries out an iteration on the returned entities to create dynamically the lines of a grid.
The block token is inserted in the HTML page by using following syntax:
<table>
<!adx="MyBlock">
<tr>
<td adx="aBLKELMTRANK"></td>
<td adx="ITEMREF"></td>
</tr>
<!adx="MyBlock">
</table>
The XTEND engine processes the blocks as follows:
This stage is performed only once when the HTML page is loaded:
This stage is carried out each time the HTML page is displayed:
1. Block initialization
2. Iteration on all returned entities
In previous example, if the selection displays 3 products of code PUZ001, PUZ002 and PUZ003, a 3-line grid will be obtained:
1 | PUZ001 | |
2 | PUZ002 | |
3 | PUZ003 |
The generated HTML is as follows:
The HTML 'child' of the block token was repeated 3 times and was recalculated each time with respect to the new data context (current line).
<table>
<tr>
<td>1</td>
<td>PUZ001</td>
</tr>
<tr>
<td>2</td>
<td>PUZ002</td>
</tr>
<tr>
<td>3</td>
<td>PUZ003</td>
</tr>
</table>
The block token not only displays data grids, it also manages the dynamic modification of selection and sort criteria.
The block setups set the default criteria and it is possible to authorize or deny the modification of these criteria by a dynamic link.
The dynamic link token can modify the block criteria and it is also possible to define selection and sort setups for this token.
Only the selection and sort criteria or the page main block (alias AMAIN) can be modified by the dynamic link criteria.
It is possible to define several blocks by page, but only one of them (the main block) has selection and sort criteria that can be modified by the user.
There are three types of modification via dynamic link for the block criteria:
These three options make it possible to handle most situations occurring in Web pages.
The block token record is used to set up the block selection and sort criteria.
These are the default criteria applied at first display of the page containing the block.
The block token proposes two setups 'Modifiable selection' and 'Modif. sorting' indicating if the selection criteria and/or sort criteria can be modified by a dynamic link.
These setups are only applied if the block was defined as main block in the record of the Web page displaying it.
In order to display a block with several cells by line, the specific token ASTAMP is used to delineate the cell.
The XTEND server repeats the HTML code present between the two ASTAMP tags as many times as cells in the line.
<table>
<!-Iteration on the lines of the block-->
<!adx="MYBLOCK">
<tr>
<!-Code repeated as much as there are cells by line'-->
<!adx="ASTAMP">
<!--to alternate the color of the cells-->
<td adx="ALINESTYLE:xattr=Class">
<!--HTML code of a cell-->
<b>Name</b><p adx="NAME"></p>
<b>First name</b><p adx="FIRSTNAME"></p>
</td>
<!adx="ASTAMP">
</tr>
<!adx="MYBLOCK">
</table>
The example below shows how to fill empty cells when the number of recordings is not a multiple of the number of cells by line.
The conditioned blockADISPSTAMPEMPTY is used to define the HTML dedicated to the empty cells.
<table>
<!-Iteration on the block lines-->
<!adx="MYBLOCK">
<tr>
<!adx="ASTAMP">
<td adx="ALINESTYLE:xattr=Class">
<!adx="ADISPSTAMPEMPTY">
<!--Empty cell filled with a blank-->
<!adx="ADISPSTAMPEMPTY">
<!adx="ADISPSTAMPEMPTY:xnot">
<!--HTML code of a non empty cell-->
<b>Nom</b><p adx="NAME"></p>
<b>Prénom</b><p adx="FIRSTNAME"></p>
<!adx="ADISPSTAMPEMPTY">
</td>
<!adx="ASTAMP">
</tr>
<!adx="MYBLOCK">
</table>
The actions ABLKFIRSTPAGE, ABLKNEXTPAGE, ABLKPREVPAGE, ABLKLASTPAGE are used to manage the page numbering in the blocks.
The tokens ADLKFIRSTPAGE, ADLKNEXTPAGE, ADLKPREVPAGE, ADLKLASTPAGE can be used on the page main block.
The fields aBLKNBELMTS and APAGEPOS display the total number of recordings and the position of the page compared to the total page number.
The conditioned blocks AHIDEMAINFIRSTPAGE and AHIDEMAINLASTPAGE manage the display/hide status of page numbering buttons for the first and last pages.
Syntax
MonBloc.ADLK*
For example:
Page numbering with display management at start and end of page numbering.
<table width="100%">
<tr>
<td align="left" width="20%">
<!--Hide FirstPage and Previous actions if current page is the first page-->
<!adx="aHideMainFirstPage">
<!---->
<a href="" adx="AMAIN.aDlkFirstPage">First</a>
<a href="" adx="AMAIN.aDlkPrevPage">Previous</a>
<!adx="aHideMainFirstPage">
</td>
<!--Displays page information-->
<td align="center" width="60%">
Page: <span adx="AMAIN.aPagePos"></span> -
Number of elements: <span adx="AMAIN.aBlkNbElmts"></span>
</td>
<td align="right" width="20%">
<!--Hide LastPage and Next actions if current page is the last page-->
<!adx="aHideMainLastPage">
<a href="" adx="AMAIN.aDlkNextPage">Next</a>
<a href="" adx="AMAIN.aDlkLastPage">Dernière</a>
<!adx="aHideMainLastPage">
</td>
</tr>
</table>
The dynamic links ADLKSELECT and ADLKUNSELECT (action ABLKSELECT and ABLKUNSELECT) are used to select/deselect a block line.
Use
Insert the tokens ADLKSELECT and ADLKUNSELECT in one of the line cells either in a tag <a> or in a tag <input type='button'>.
The field ABLKSELECTEDLINE contains the rank (1 to N) of the selected line.
For example:
The block ABLKCOUNTRIES displays the countries in the site ASAMPLE with selection of the line to display the detail Currency/Country language.
A click on the first cell (CRY) selects the line.
<!adx="ABLKCOUNTRIES:xselect=false">
<tr>
<td><a adx="ADLKSELECT"><span adx="CRY"></span></a></td>
<td adx="CRYDES"></td>
<td adx="CUR"></td>
<td adx="LAN"></td>
</tr>
<!adx="ABLKCOUNTRIES">
<!--Display the no. of lines selected-->
<span adx='ABLKCOUNTRIES.ABLKSELECTEDLINE'></span>
The HTML setup 'xSelect=true' is used to select the first line by default.
If this setup is not used, or if its value is 'false', the block has no selected line by default.
When a block has a selected line, it is possible to access the fields of this line via the syntax MyBlock.MyField.
The values of the fields of the selected line can be displayed or used as criteria in a block, dynamic link, or conditioned block.
The conditioned block AHIDEMAINSELECT displays/hides an HTML zone taking into account whether the main block has a selected line or not (see country page of site ASAMPLE).
The action ABLKRESTOREMAINCTX is used to get back to a list page from a detail page without loosing the page numbering or the selected line of the main block.
The dynamic link below is used to get back to the page FORMQUERYRES and restore the main block context.
<input type="button" value="Return list" adx="DlkFrmQueryBack" class="xtendButton" >
The following syntax is used to access directly the data of a block line:
<!--First line-->
<span adx="MYBLOCK(first).MYFIELD"></span>]<br>
<!--Last line-->
<span adx="MYBLOCK(last).MYFIELD"></span>]<br>
<!--N line-->
<span adx="MYBLOCK(N).MYFIELD"></span>]<br>
The following syntax is used to value a JavaScript variable with the JSON representation of a block or block line:
<script>
// JSON data of a block
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*)">;
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*):xinclude=FIELD1,FIELD2">;
var wMyBlock_JSON=<!adx="MYBLOCK(*)"><!adx="MYBLOCK(*):xexclude=FIELD1,FIELD2">;
// JSON data of a line
var wMyLine_JSON=<!adx="MYBLOCK(2)"><!adx="MYBLOCK(2)">;
var wMyLine_JSON=<!adx="MYBLOCK(2):xinclude=FIELD1,FIELD2"><!adx="MYBLOCK(2)">;
var wMyLine_JSON=<!adx="MYBLOCK(2):xexclude=FIELD1,FIELD2"><!adx="MYBLOCK(2)">;
</script>
The JSON variable of a block is composed of an array of lines:
<script>
var wMyBlock = [{line 1},{line 2},...];
var wMyBlock = [{"STATUT":1,"STATUT_DESCR":"To process","PRIX":81.35,"COD2":"30-112"},
{"STATUT":2,"STATUT_DESCR":"Processed","PRIX":117.9,"COD2":"31-02"},
{"STATUT":1,"STATUT_DESCR":"To process","PRIX":606.15,"COD2":"32-034"}];
</script>
The JSON variable of a line is an object containing fields:
<script>
var wMyLine ={"FIELD1":"Value1","FIELD2":"Value2"...};
var wMyLine = {"STATUS":1,"STATUS_DESCR":"To process","PRICE":606.15,"COD2":"32-034"}
</script>
For a field, the xjson setup generates a JSON object {"FieldName:"Value"}. Without xjson setup, the JavaScript variable is valued with the field value.
<script>
// JSON data of a field
var wMyField_JSON=<!adx="MYFIELD:xjson"><!adx="MYFIELD">;
//XTEND generates
var wMyField_JSON={"MYFIELD":"Value"};
// Field value
var wMyField_JSON=<!adx="MYFIELD"><!adx="MYFIELD">;
//XTEND generates
var wMyField_JSON="Value";
</script>
Code | Setup | Effect |
xselect | True/False | Selects the first line by default |
Code | Type | Description |
ABLKELMTIDX | Integer | Index of an element in a block (O->ABLKNBELMTS-1) |
ABLKELMTRANK | Integer | Rank of an element in a block (1->ABLKNBELMTS) |
ABLKLINEIDX | Integer | Index of line in a block (O->ABLKNBELMTS-1) |
ABLKLINERANK | Integer | Rank of line in a block (O->ABLKNBLINES) |
ABLKNBELMTS | Integer | Total number of elements (recordings) of a block request |
ABLKNBLINES | Integer | Rank of the selected line of a block via action ABLKSELECT |
ABLKSELECTEDLINE | Integer | Number of lines in a block |
APAGENB | Integer | Number of pages in a block |
APAGENUM | Integer | Rank of a block current page |
APAGEPOS | Integer | APAGEPOS/APAGENUM |
Code | Description |
ACONST | Contains all fields of type constant |
ACURRENT | Current data context (top) in XDEND stack of data |
AHTMLFORM | HTML form |
AHTTPCOOKIE | HTTP cookies |
AMAIN | Main block of a page defined in the page setups |
APBG | Background block of a page defined in the page setups |
AMESS | User messages |
AREFERENCE | In the expression MyReferenceBlock.MyLinkToken, the block MyReferenceBlock corresponds to 'reference block' ; |
ASESSION | Contains the user session data |
AUSERCRIT | Contains the user criteria (HTML setup xcrit) |
AUSERINF | Contains the user data provided by the login |
AUSERVAR | Contains the user variables created by the functions JavaSCript xtdSetUserVar/xtdRemoveUserVar |
Fields
The following fields are present on this tab :
|
|
|   |
Close
Presentation
General setups of the block.
Close
Fields
The following fields are present on this tab :
Characteristics
|
|
|
|
|
|
Close
Presentation
Parameters of the selection associated with the block.
Close
Fields
The following fields are present on this tab :
Characteristics
|
|
|
Selection synthesis
|
Table Selection criteria
|
|
|
|
|
| The parameter value is entered here. Depending on the case, this value is entered as if it were a number, a date or an alphanumeric code. When the parameter is of local menu type, it is possible to enter either the beginning of the name or the numeric value corresponding to the position of the name in the list. When the code is controlled by an annex table, a selection key may be used to select it. |
|
|
|
|
|
|   |
Entity
|
|
|
Close
Fields
The following fields are present on this tab :
Characteristics
|
|
Table Sort
|
|
Close
Fields
The following fields are present on this tab :
Date returned by block
|
Table Style per line
|
Table Param sub-routine access
|
|
|
|
|
|
Close
By default, the following reports are associated to the function :
PRTSCR : Screen print
This can be changed by a different setup.
This button is used to copy a block token. |