Templates

A template is HTML code that Arcos uses as the basis of the layout of a generated web page. Arcos replaces the KTAGs in the template with HTML code in the generated pages. You can change the location of KTAGs in the template so that the generated page has the appearance you require.

There are two types of template:

In this topic, we show you how to create a template that uses KTAGs, which are used to tell Arcos how to manipulate data. Rather than creating a template from scratch, we modify an existing autotemplate.

To modify an autotemplate

  1. Copy the listFriends.html autotemplate from the /config/template/auto directory and place it in the /config/template directory.
  2. Modify the code (use the code below).
  3. Open a browser and run RefreshCache.php. The URL consists of the base URL followed by /admin/RefreshCache.php
  4. View the listFriends page in a web browser.

listFriends.html template code

<BODY BGCOLOR="#ffffee">
<TABLE border="1" cellpadding="3" cellspacing="0" bordercolor="#009900">
   <KLOOP__tblFriends>
      <TR>
         <TD COLSPAN=4>
            <input type="hidden" KFIELD__tblfriends..recordindex>
            KVALUE__tblFriends..validation=""
            <TABLE border=0 >
               <TR>
                  <TD BGCOLOR="#CCEE11">Name</TD>
                  <TD>KVALUE__tblFriends.name.=""</TD>
               </TR>
               <TR>
                  <TD BGCOLOR="#CCEE11">Telephone Number</TD>
                  <TD>KVALUE__tblFriends.tel.=""</TD>
               </TR>
               <TR>
                  <TD BGCOLOR="#CCEE11">Email Address</TD>
                  <TD>KVALUE__tblFriends.email.=""</TD>
               </TR>
               <TR>
                  <TD COLSPAN=2></TD>
               </TR>
            </TABLE>
         </TD>
      </TR>
   </KLOOP__tblFriends>
</TABLE>

Explanation of code

This code is based on the autotemplate. We don't discuss the HTML aspects. Just note that we've added a BODY tag and given the page some colour. We've also given some of the table cells some colour. The autotemplate code contained HTML that displayed the FriendID field. We have removed it from this code.

<KLOOP__tblFriends>

This loops round all the records, and causes Arcos to produce the HTML code for each of them.

<input type="hidden" KFIELD__tblfriends..recordindex>

This is an internal field which is required once within a KLOOP. It keeps track of the current record. Do not modify this.

KVALUE__tblFriends..validation=""

This line ensures that any constraints on the tblFriends table are checked. The function to do this is called validation. In our case, it's not strictly necessary to check constraints, since none are set.

The KVALUE tag retrieves a value from the recordset, based upon what is specified in the latter part of the tag. The structure is: KVALUE__table.field.function=""
Since you can only retrieve one value at a time, there will always be two dots somewhere in the KVALUE tag. Note that there are two underscore characters.

The ="" characters are optional. They are strictly not part of the KTAG, but they are added for compatibility with DreamWeaver.

KVALUE__tblFriends.name.=""

This line causes Arcos to display the value of the Name field for the current record.