Archive 1.x:Sample Swimming Pool Record Template

From OSF Wiki
Jump to navigation Jump to search

Here is a sample Smarty record template page in PHP for presenting an indoor swimmiing pool record. NOTE: Renderings for this code are presented at the bottom of this document. The nominal source file is now_indoor_swimming_pools.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'}
    {attribute->getValues attribute='http://www.geonames.org/ontology#locatedIn' assign='locatedIn'}
    {attribute->getValues attribute='http://www.w3.org/2003/01/geo/wgs84_pos#lat' assign='lat'}
    {attribute->getValues attribute='http://www.w3.org/2003/01/geo/wgs84_pos#long' assign='long'}
    {attribute->getValues attribute='http://www.w3.org/2003/01/geo/wgs84_pos#alt' assign='alt'}
    
    {attribute->getValues attribute='http://purl.org/ontology/now#isOpen' assign='isOpen'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#lockersDesc' assign='lockersDesc'} {* String *}
    {attribute->getValues attribute='http://xmlns.com/foaf/0.1/homepage' assign='homepage'} {* URL *}
    {attribute->getValues attribute='http://purl.org/ontology/now#poolEntry' assign='poolEntry'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#effectiveFromDate' assign='effectiveFromDate'} {* Date *}
    {attribute->getValues attribute='http://purl.org/ontology/now#effectiveToDate' assign='effectiveToDate'} {* Date *}
    {attribute->getValues attribute='http://purl.org/ontology/now#fitnessProgramsDesc' assign='fitnessProgramsDesc'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#entryHeightRequirement' assign='entryHeightRequirement'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#lapSwimDesc' assign='lapSwimDesc'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#streetAddress' assign='streetAddress'} {* Address *}
    {attribute->getValues attribute='http://purl.org/ontology/now#ownedBy' assign='ownedBy'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#maintainedBy' assign='maintainedBy'} {* String *}
    {attribute->getValues attribute='http://purl.org/ontology/now#memberOfComplex' assign='memberOfComplex'} {* URI *}
    {attribute->getValues attribute='http://purl.org/ontology/now#operateBy' assign='operateBy'} {* String *}

    {attribute->getValues attribute='http://purl.org/ontology/now#hasGroupGatheringCapabilities' assign='hasGroupGatheringCapabilities'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasWeightRoom' assign='hasWeightRoom'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasDivingBoard' assign='hasDivingBoard'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasParkingLot' assign='hasParkingLot'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasWhirlpool' assign='hasWhirlpool'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasMerchandiseSales' assign='hasMerchandiseSales'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasSauna' assign='hasSauna'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasSpecialtyChangeRoom' assign='hasSpecialtyChangeRoom'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasRoomRentals' assign='hasRoomRentals'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasLapSwim' assign='hasLapSwim'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasPoolSlide' assign='hasPoolSlide'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasLockers' assign='hasLockers'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasSwimLessons' assign='hasSwimLessons'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasIndoorTrack' assign='hasIndoorTrack'} {* Yes/No *}
    {attribute->getValues attribute='http://purl.org/ontology/now#hasFitnessPrograms' assign='hasFitnessPrograms'} {* Yes/No *}

 
    {attribute->getValues attribute='http://purl.org/ontology/wsf#crudAction' assign='crudAction'} {* --- to ignore *}
    {attribute->getValues attribute='http://purl.org/ontology/sco#namedEntity' assign='isNamedEntity'} {* --- to ignore *}
    
    
	  {* ----------------------------------------- *}

	  {attribute->getUnasigned assign='unasignedAttributes'}

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

    <title>{if $InstanceRecordLabel != ''}{$InstanceRecordLabel} indoor swimming pool{else}indoor swimming pool{/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/now_indoor_swimming_pools.css" />

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    
    <style type="text/css">
      html {ldelim} height: 100% {rdelim}
      body {ldelim} height: 100%; margin: 0; padding: 0 {rdelim}
      #map_canvas {ldelim} height: 100% {rdelim}
    </style>
    
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
             
  </head>

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

  <body>

    <script type="text/javascript">
      $(document).ready(function()
      {ldelim}
        var latlng = new google.maps.LatLng({$lat[0].value}, {$long[0].value});
        var myOptions = {ldelim}
          zoom: 15,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        {rdelim};
        
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        
        var marker = new google.maps.Marker({ldelim}
            position: latlng, 
            map: map, 
            icon: "http://npidev.structureddynamics.com/sites/all/modules/conStruct/templates/imgs/swimming.png",          
            title: "{$InstanceRecordLabel} indoor swimming pool - {$streetAddress[0].value}"
        {rdelim});          
        
      {rdelim});      
    </script>  
  
    <div id="tBody">
    
      <table id="tMainCharacteristicsTable">
        <tbody>
          <tr>
            <td id="tLeftInformationColumn" valign="top">
            
              The {$InstanceRecordLabel} indoor swimming pool is located in 
              the <a href="{$locatedIn[0].value}">{$locatedIn[0].valueLiteral}</a>.
              
              <h2>General Information</h2>
              
              <ul>
                {if $homepage[0].value != ""}
                  <li><img src="{$templateLocationUrl}imgs/house_link.png" /> <a href="{$homepage[0].value}" title="homepage">{$InstanceRecordLabel} indoor swimming pool homepage</a></li>
                {/if}
                
                {if $streetAddress[0].value != ""}
                  <li>Its street address is <b>{$streetAddress[0].value}</b></div></li>
                {/if}

                {if $isOpen[0].value != ""}
                  {if $isOpen[0].value|lower == "yes"}
                    <li>This indoor pool is currently open.</li>
                  {/if}
                  {if $isOpen[0].value|lower == "no"}
                    <li>This indoor pool is <b>not</b> currently open.</li>
                  {/if}
                {/if}
              
                {if $poolEntry[0].value != ""}
                  <li>Special entries for the pool: {$poolEntry[0].value}</li>
                {/if}
              
                {if $entryHeightRequirement[0].value != ""}
                  <li>Minimum height requirement to enter the pool: {$entryHeightRequirement[0].value}</li>
                {/if}
              </ul>
              
              <h2>Amenities</h2>
              
              <table>
                <tbody>
                  {if $hasGroupGatheringCapabilities[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/party-2.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has group gathering capabilities
                      </td>
                    </tr>
                  {/if}
                  {if $hasWeightRoom[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/weights.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has weight room
                      </td>
                    </tr>
                  {/if}
                  {if $hasDivingBoard[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/diving.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has diving board
                      </td>
                    </tr>
                  {/if}
                  {if $hasParkingLot[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/parking.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has parking lot
                      </td>
                    </tr>
                  {/if}
                  {if $hasWhirlpool[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/swimming.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has whirlpool
                      </td>
                    </tr>
                  {/if}
                  {if $hasMerchandiseSales[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/supermarket.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Sells marchandise on site
                      </td>
                    </tr>
                  {/if}
                  {if $hasSauna[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/swimming.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has sauna
                      </td>
                    </tr>
                  {/if}
                  {if $hasSpecialtyChangeRoom[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/disability.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has specialty change room
                      </td>
                    </tr>
                  {/if}                  
                  {if $hasLockers[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/lockerrental.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has locker rentals. {if $lockersDesc[0].value != ""} <div>Description: {$lockersDesc[0].value}</div> {/if}
                      </td>
                    </tr>
                  {/if}                  
                  {if $hasRoomRentals[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/lockerrental.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has room rentals
                      </td>
                    </tr>
                  {/if}        
                  {if $hasSwimLessons[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/swimming.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has swimming lessons
                      </td>
                    </tr>
                  {/if}
                  {if $hasPoolSlide[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/swimming.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has pool slide
                      </td>
                    </tr>
                  {/if}
                  {if $hasLapSwim[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/swimming.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has lap swim. {if $lapSwimDesc[0].value != ""} <div>Description: {$lapSwimDesc[0].value}</div> {/if}
                      </td>
                    </tr>
                  {/if}
                  {if $hasIndoorTrack[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/jogging.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has indoor tracks
                      </td>
                    </tr>
                  {/if}                  
                  {if $hasFitnessPrograms[0].value|lower == "yes"}
                    <tr>
                      <td class="amenitiesIconColumn" valign="middle">
                        <img src="{$templateLocationUrl}imgs/fitness.png" />
                      </td>
                      <td class="amenitiesDescriptionColumn" valign="middle">
                        Has fitness programs. 
                        {if $fitnessProgramsDesc[0].value != ""} <div>Description: {$fitnessProgramsDesc[0].value}</div> {/if}
                      </td>
                    </tr>
                  {/if}                  
                </tbody>
              </table>
              
            </td>
            <td id="tMapColumn" valign="top">
              {if $lat != ""  && $long != ""}
                <div id="map_canvas" style="width:250px; height:250px;"></div>  
              {/if}
            </td>
          </tr>
        </tbody>
      </table>
    
    
      
      {* If there are attributes/values that haven't been assigned to any template variable, then we simply
         list them into an "Other Information" tw-column table *}
      {if count($unasignedAttributes) > 0}
        <h3 id="tOtherInformationTitle">Other Information</h3>
        <table id="tAttributesValuesTable">
          <tbody>
            {foreach from=$unasignedAttributes item=value}
              {if $value.valueType == "resource"}
              
                <tr>
                  <td class="tAttributeColumn" valign="top">
                    <span>
                      {$value.attributeLabel}:
                    </span>
                  </td>
                  <td class="tValueColumn" valign="top">
                    <a href="?uri={$value.value}&dataset={$InstanceRecordDataset}">{$value.valueLiteral}</a> 
                  </td>
                </tr>
              {else}              
                <tr>
                  <td class="tAttributeColumn" valign="top">
                    <span>
                      {$value.attributeLabel}:
                    </span>
                  </td>
                  <td class="tValueColumn" valign="top">
                    {$value.valueLiteral} 
                  </td>
                </tr>
              {/if}
            {/foreach}
              
          </tbody>
        </table>
      {/if}
      
    </div>
    
  </body>

</html>

Record View

Here is a rendering of this record template while in individual record 'View' mode:

Swimming pool view.png

Browse Record

Here is a rendering of a recordset record template for this same record. This record view has been generated by the structBrowse OSF-Drupal tool, and is used the resultset records templates.

Swimming pool browse.png