Sample Topic Template

From TechWiki

Jump to: navigation, search

Here is a sample Drupal template page in PHP for a topic layout. The nominal source file is page-topic.tpl.php:

<?php
 
  $targetConcept = "http://purl.org/ontology/npi#NPI_Topics";
 
  if(isset($node->field_topics_uri[0]['value']) && $node->field_topics_uri[0]['value'] != "")
  {
    $start = strrpos($node->field_topics_uri[0]['value'], "(") + 1;
    $end = strrpos($node->field_topics_uri[0]['value'], ")");
    $targetConcept = substr($node->field_topics_uri[0]['value'], $start, ($end - $start));
  }
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>">
 
  <head>
    <title><?php print $head_title; ?></title>
    <?php print $styles; ?>
    <!--[if IE 7]>
      <link rel="stylesheet" href="<?php print $base_path . $directory; ?>/ie7-fixes.css" type="text/css">
    <![endif]-->
    <!--[if lte IE 6]>
      <link rel="stylesheet" href="<?php print $base_path . $directory; ?>/ie6-fixes.css" type="text/css">
    <![endif]-->
    <?php print $scripts; ?>
    <?php print $head; ?>
 
    <!--  BEGIN Browser History required section -->
    <link rel="stylesheet" type="text/css" href="http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/history/history.css" />
    <!--  END Browser History required section -->
 
    <script src="http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/AC_OETags.js" language="javascript"></script>
 
    <!--  BEGIN Browser History required section -->
    <script src="http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/history/history.js" language="javascript"></script>
    <!--  END Browser History required section -->
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" language="javascript"></script>
 
    <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/css/sRelationBrowser.css?f" />
 
    <script language="JavaScript" type="text/javascript">
    <!--
    // -----------------------------------------------------------------------------
    // Globals
    // Major version of Flash required
    var requiredMajorVersion = 10;
    // Minor version of Flash required
    var requiredMinorVersion = 0;
    // Minor version of Flash required
    var requiredRevision = 0;
    // -----------------------------------------------------------------------------
    // -->
    </script>    
 
  </head>
 
  <body class="<?php print $body_classes; ?>">
    <div id="page" class="clearfix">
 
      <div id="header">
        <div id="header-wrapper" class="clearfix">
 
          <div id="header-top" class="clearfix">
            <?php if ($primary_links): ?>
          <div id="primary-menu">
            <?php print $primary_links_tree; ?>
          </div><!-- /primary_menu -->
          <?php endif; ?>
          </div><!-- /header-top --> 
 
          <?php if ($search_box): ?>
          <div id="search-box">
            <?php print $search_box; ?>
          </div><!-- /search-box -->
          <?php endif; ?>
 
          <div id="header-first">
            <?php if ($logo): ?> 
            <div id="logo">
              <a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a>
            </div>
            <?php endif; ?>
          </div><!-- /header-first -->
 
          <div id="header-middle">
            <?php if ($header_middle): ?>
            <?php print $header_middle; ?>
            <?php endif; ?>
            <?php if ($site_name): ?>
		    <div id="title"> 
              <a href="<?php print $base_path ?>" title="<?php print t('Home'); ?>"><?php print $site_name; ?></a>
			</div>
            <?php endif; ?>
            <?php if ($site_slogan): ?>
            <div id="slogan">
			  <?php print $site_slogan; ?>
			</div>
            <?php endif; ?>	
            <?php if ($mission): ?>
            <div id="mission"> 
              <?php print $mission; ?>
            </div>
            <?php endif; ?>			
          </div><!-- /header-middle -->
 
          <div id="header-last">
            <?php if ($header_last): ?>
            <?php print $header_last; ?>
            <?php endif; ?>
          </div><!-- /header-last -->
 
        </div><!-- /header-wrapper -->
 
        <div id="header-bottom" class="clearfix">
        </div><!-- /header-bottom -->
 
		</div><!-- /header -->
 
      <div id="preface">
        <?php if ($preface_first || $preface_middle || $preface_last): ?>
        <div id="preface-wrapper" class="<?php print $prefaces; ?> clearfix">
 
          <?php if ($preface_first): ?>
          <div id="preface-first">
            <?php print $preface_first; ?>
          </div><!-- /preface-first -->
          <?php endif; ?>
 
          <?php if ($preface_middle): ?>
          <div id="preface-middle">
            <?php print $preface_middle; ?>
          </div><!-- /preface-middle -->
          <?php endif; ?>
 
          <?php if ($preface_last): ?>
          <div id="preface-last">
            <?php print $preface_last; ?>
          </div><!-- /preface-last -->
          <?php endif; ?>
        </div><!-- /preface-wrapper -->
        <?php endif; ?>
      </div><!-- /preface -->
 
	  <div id="tri-bar" class="clearfix">
	    <div id="tri-bar-1">&nbsp;</div>
		<div id="tri-bar-2">&nbsp;</div>
	  </div><!-- /tri-bar -->
 
      <div id="main">
        <div id="main-wrapper" class="clearfix">
 
          <?php if ($breadcrumb): ?>
          <div id="breadcrumb">
            <?php print $breadcrumb; ?>
          </div><!-- /breadcrumb -->
          <?php endif; ?>
 
          <?php if ($sidebar_first): ?>
          <div id="sidebar-first">
            <?php print $sidebar_first; ?>
          </div><!-- /sidebar-first -->
          <?php endif; ?>
          <div id="content-wrapper">
 
            <?php if ($messages): ?>
              <?php print $messages; ?>
            <?php endif; ?>
 
            <?php if ($content_top): ?>
            <div id="content-top">
              <?php print $content_top; ?>
            </div><!-- /content-top -->
            <?php endif; ?>
 
            <div id="content">
              <?php if ($tabs): ?>
              <div id="content-tabs">
                <?php print $tabs; ?>
              </div>
              <?php endif; ?>
 
              <div id="content-inner">
              <?php if ($help): ?>
                <div id="help">
                  <?php print $help; ?>
                </div>
              <?php endif; ?>
 
                <?php /* if ($title): ?>
                <h1 class="title"><?php print $title; ?></h1>
                <?php endif;*/ ?>
 
                <?php
                  if(stripos($_GET['q'], "/edit") !== FALSE)
                  {
                ?>
 
                <div id="content-content">
                  <?php print $content; ?>
                </div>
 
                <?php
                  }
                ?>
 
 
      </div><!-- /content-inner -->
            </div><!-- /content -->
 
            <?php
              if(stripos($_GET['q'], "/edit") === FALSE)
              {
            ?>
 
 
              <div id="relationBrowser" class="relationBrowser" style="width: 735px; height: 735px;">
 
              <script language="JavaScript" type="text/javascript">
              <!--
              // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
              var hasProductInstall = DetectFlashVer(6, 0, 65);
 
              // Version check based upon the values defined in globals
              var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
 
              if ( hasProductInstall && !hasRequestedVersion ) {
              // DO NOT MODIFY THE FOLLOWING FOUR LINES
              // Location visited after installation is complete if installation is required
              var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
              var MMredirectURL = window.location;
              document.title = document.title.slice(0, 47) + " - Flash Player Installation";
              var MMdoctitle = document.title;
 
              AC_FL_RunContent(
                      "src", "http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/playerProductInstall.swf",
                      "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
                      "width", "100%",
                      "height", "100%",
                      "align", "middle",
                      "id", "PortableControlApplication",
                      "quality", "high",
                      "bgcolor", "#869ca7",
                      "name", "PortableControlApplication",
                      "allowScriptAccess","sameDomain",
                      "type", "application/x-shockwave-flash",
                      "wmode", "transparent",
                      "pluginspage", "http://www.adobe.com/go/getflashplayer"
              );
              } else if (hasRequestedVersion) {
              // if we've detected an acceptable version
              // embed the Flash Content SWF when all tests are passed
              AC_FL_RunContent(
                              "src", "http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/PortableControlApplication.swf",
                              "width", "100%",
                              "height", "100%",
                              "align", "middle",
                              "id", "PortableControlApplication",
                              "quality", "high",
                              "bgcolor", "#869ca7",
                              "name", "PortableControlApplication",
                              "allowScriptAccess","sameDomain",
                              "wmode", "transparent",
                              "allowFullScreen", "true",
 
 
              /* relationBrowser */
              "flashVars", "baseAppUrl=http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/&settingsFolder=relationbrowser/settings/&inputSchemas=http://npidev.structureddynamics.com/schemas/npi.xml&inputTargetRecords=<?php echo urlencode($targetConcept); ?>&inputTargetAttributes=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23subClassOf&inputData=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%3C!DOCTYPE%20resultset%20PUBLIC%20%22-%2F%2FStructured%20Dynamics%20LLC%2F%2FCrud%20Read%20DTD%200.1%2F%2FEN%22%20%22crud%2FcrudRead.dtd%22%3E%0A%3Cresultset%3E%0A%20%20%3Cprefix%20entity%3D%22owl%22%20uri%3D%22http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23%22%2F%3E%0A%20%20%3Cprefix%20entity%3D%22rdf%22%20uri%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%2F%3E%0A%20%20%3Cprefix%20entity%3D%22rdfs%22%20uri%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%22%2F%3E%0A%20%20%3Cprefix%20entity%3D%22wsf%22%20uri%3D%22http%3A%2F%2Fpurl.org%2Fontology%2Fwsf%23%22%2F%3E%0A%20%20%3Csubject%20type%3D%22http%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23Class%22%20uri%3D%22<?php echo urlencode($targetConcept); ?>%22%3E%0A%20%20%3C%2Fsubject%3E%0A%3C%2Fresultset%3E",
 
 
                              "type", "application/x-shockwave-flash",
                              "pluginspage", "http://www.adobe.com/go/getflashplayer"
              );
              } else {  // flash is too old or we can't detect the plugin
              var alternateContent = 'Alternate HTML content should be placed here. '
              + 'This content requires the Adobe Flash Player. '
              + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
              document.write(alternateContent);  // insert non-flash content
              }
              // -->
              </script>
 
 
              <noscript>
                      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                                      id="PortableControlApplication" width="100%" height="100%"
                                      codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
                                      <param name="movie" value="http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/PortableControlApplication.swf" />
                                      <param name="quality" value="high" />
                                      <param name="bgcolor" value="#869ca7" />
                                      <param name="allowScriptAccess" value="sameDomain" />
                                      <param name="allowFulllScreen" value="true" />
                                      <param name="wmode" value="transparent" />
                                      <embed src="http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/PortableControlApplication.swf" quality="high" bgcolor="#869ca7"
                                              width="100%" height="100%" name="PortableControlApplication" align="middle"
                                              play="true"
                                              loop="false"
                                              quality="high"
                                              allowScriptAccess="sameDomain"
                                              allowFullScreen="true"
                                              type="application/x-shockwave-flash"
                                              pluginspage="http://www.adobe.com/go/getflashplayer">
                                      </embed>
                      </object>
              </noscript>
              </div> <!-- relationBrowser -->       
 
          <?php
            }
          ?>
 
 
            <?php if ($content_bottom): ?>
            <div id="content-bottom">
              <?php print $content_bottom; ?>
            </div><!-- /content-bottom -->
            <?php endif; ?>
 
 
		</div><!-- /content-wrapper -->
 
                <?php if ($sidebar_last): ?>
                <div id="sidebar-last">
                  <?php print $sidebar_last; ?>
                </div><!-- /sidebar_last -->
                <?php endif; ?>
 
 
          <?php if ($postscript_first || $postscript_middle || $postscript_last): ?>
          <div id="postscript-wrapper" class="<?php print $postscripts; ?> clearfix">
            <?php if ($postscript_first): ?>
            <div id="postscript-first" class="column">
              <?php print $postscript_first; ?>
            </div><!-- /postscript-first -->
            <?php endif; ?>
 
            <?php if ($postscript_middle): ?>
            <div id="postscript-middle" class="column">
              <?php print $postscript_middle; ?>
            </div><!-- /postscript-middle -->
            <?php endif; ?>
 
            <?php if ($postscript_last): ?>
            <div id="postscript-last" class="column">
              <?php print $postscript_last; ?>
            </div><!-- /postscript-last -->
            <?php endif; ?>
          </div><!-- /postscript-wrapper -->
          <?php endif; ?>
 
          <?php print $feed_icons; ?>   
 
        </div><!-- /main-wrapper -->
      </div><!-- /main -->
      <?php if ($footer_top || $footer || $footer_message): ?>
        <div id="footer" class="clearfix">
          <?php if ($footer_top): ?>
          <?php print $footer_top; ?>
          <?php endif; ?>
          <?php if ($footer): ?>
          <?php print $footer; ?>
          <?php endif; ?>
          <?php if ($footer_message): ?>
          <?php print $footer_message; ?>
          <?php endif; ?>
        </div><!-- /footer -->
	  <?php endif; ?>
	  </div><!-- /page -->
    <?php print $closure; ?>
  </body>
</html>
Personal tools