Sample Generic 'Thing' Record Template

From TechWiki

Jump to: navigation, search

Here is a sample Smarty record template page in PHP for presenting generic (owl:Thing) records. This particular template is used when no other more specific template is available for the record type on hand. Thus, this template format is the default "fallback" template for any record without an overriding template type. The nominal source file is owl_thing.tpl:

<!-- $Id$ -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

  <head>

    {*
      // Tells the templating engine to check for linksTo relationships.
      setting->LinksTo=false
     
      // Tells the templating engine NOT to include labels for object resources
      setting->setAttributeIgnoreResourceLabel=false
    *}
 

          {* Attributes assignation: assignation of pre-defined variables *}           

          {attribute->getInstanceRecordType assign='InstanceRecordType'}
          {attribute->getInstanceRecordDescription assign='InstanceRecordDescription'}
          {attribute->getInstanceRecordLabel assign='InstanceRecordLabel'}
          {attribute->getInstanceRecordDataset assign='InstanceRecordDataset'}
   
    {* Uncomment this attribute assignation if you want to display links of the records that refers to  
       the one currently viewed. *}

     
          {*attribute->getLinksTo assign='linksTo'*}

          {* ----------------------------------------- *}

          {attribute->getUnasigned assign='unasignedAttributes'}

    {php}
      // Set the template folder URL into a smarty variable
      $this->assign('templateLocationUrl', $this->templateLocationUrl);
    {/php}          
   

    <title>{if $InstanceRecordLabel != ''}{$InstanceRecordLabel}{else}Untitled {$InstanceRecordType}{/if}</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

          {*
                          Used to specify the CSS file related to this template. Put only the name of the file here. The name will be resolved by

                          the node in the folder "*/templates/css/file_name.css".
          *}


          <link type="text/css" rel="stylesheet" media="all" href="{$templateLocationUrl}css/owl_thing.css" />

  </head>

  {*
    IMPORTANT NOTE:
   
              Only what is within the body of this XHTML template will be used to skin the data type
  *}


  <body>

    <div id="tBody">
   
      {* If a description of the record is available, we display it *}    
      {if $InstanceRecordDescription != ''}
        <div id="tDescription">{$InstanceRecordDescription}</div>
      {/if}
     
      {if count($unasignedAttributes) > 0}
        <table id="tAttributesValuesTable">
          <tbody>
            {foreach from=$unasignedAttributes item=value}
              {if $value.valueType == "resource"}
             
                <tr>
                  <td class="tAttributeColumn">
                    <span>
                      {$value.attributeLabel}:
                    </span>
                  </td>
                  <td class="tValueColumn">
                    <a href="?uri={$value.value|escape:'url'}">{$value.valueLiteral}</a>
                  </td>
                </tr>
              {else}              
                <tr>
                  <td class="tAttributeColumn">
                    <span>
                      {$value.attributeLabel}:
                    </span>
                  </td>
                  <td class="tValueColumn">
                    {$value.valueLiteral}
                  </td>
                </tr>
              {/if}
            {/foreach}
             
          </tbody>
        </table>
      {/if}
     
    </div>
   
  </body>

</html>
Personal tools