Sample Chart Template
From TechWiki
Here is a sample Drupal template page in PHP for a chart layout. The nominal source file is page-chart.tpl.php:
<?php $indicators = "["; if(isset($node->field_target_indicator_census) && !isset($_GET["map"])) { foreach($node->field_target_indicator_census as $field) { if($field["value"] !== NULL && $field["value"] != "") { $start = strrpos($field["value"], "(") + 1; $end = strrpos($field["value"], ")"); $uri = substr($field["value"], $start, ($end - $start)); $indicators .= '"'.$uri."\","; } } } $indicators = trim($indicators, ",")."]"; ?> <!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> <script src="<?php print base_path() . path_to_theme() ?>/js/census.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/resultset.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jquery.cookie.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/swfobject.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/css/census.css?f" /> <!--script src="<?php print base_path() . path_to_theme() ?>/js/sWebMap-templates.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jquery.autocomplete-webmap.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jquery.pagination.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jquery.scrollTo-1.4.2.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jsDraw2D.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/jquery.cookie.js?f" language="javascript"></script> <script src="<?php print base_path() . path_to_theme() ?>/js/pure.js?f" language="javascript"></script> <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/css/sWebMap.css?f" /> <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/css/sexy.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> <script language="JavaScript" type="text/javascript"> var network = "http://npidev.structureddynamics.com/ws/"; var indicators = <?php echo $indicators; ?>; </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"> </div> <div id="tri-bar-2"> </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" style="width: 744px;"> <?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) { ?> <table> <tbody style="border: none;"> <tr> <td valign="top"> <table> <tbody style="border: none;"> <tr> <td> <div id="tabWidgets" onclick="switchTabWidgets();">Charts</div> <div id="tabTables" onclick="switchTabTables();">Tables</div> </td> </tr> <tr> <td> <div id="indicatorsContainerWidgets"></div> <div id="indicatorsContainerTables"></div> </td> </tr> </tbody> </table> </td> <td valign="top"> <div id="mapCanvas"> <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/playerProductInstall", "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", "pluginspage", "http://www.adobe.com/go/getflashplayer", "wmode", "transparent" ); } 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", "flashVars", "baseAppUrl=http://npidev.structureddynamics.com/sites/all/modules/conStruct/framework/flex/PortableControlApplication/&settingsFolder=map/settings/&inputSchemas=http%3A%2F%2Fnpidev.structureddynamics.com%2Fsites%2Fnpidev.structureddynamics.com%2Fschemas%2Fpeg.xml&inputTargetRecords=http%3A%2F%2Finput-target-record&inputTargetAttributes=http%3A%2F%2Fpurl.org%2Fontology%2Fsco%23gisMap;http%3A%2F%2Fpurl.org%2Fontology%2Fsco%23relatedGisMap&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%2Fpurl.org%2Fontology%2Fpeg%23City%22%20uri%3D%22http%3A%2F%2Finput-target-record%22%3E%0A%20%20%20%20%3Cpredicate%20type%3D%22http%3A%2F%2Fpurl.org%2Fontology%2Fsco%23gisMap%22%3E%0A%20%20%20%20%20%20%3Cobject%20type%3D%22rdfs%3ALiteral%22%3Ehttp%3A%2F%2Fnpidev.structureddynamics.com%2Fsites%2Fnpidev.structureddynamics.com%2Fmaps%2FPopulationTrends1971-2006.map%3C%2Fobject%3E%0A%20%20%20%20%3C%2Fpredicate%3E%0A%20%20%20%20%3Cpredicate%20type%3D%22http%3A%2F%2Fpurl.org%2Fontology%2Fsco%23relatedGisMap%22%3E%0A%20%20%20%20%20%20%3Cobject%20type%3D%22rdfs%3ALiteral%22%3Ehttp%3A%2F%2Fnpidev.structureddynamics.com%2Fsites%2Fnpidev.structureddynamics.com%2Fmaps%2Fcommunityarea.map%3C%2Fobject%3E%0A%20%20%20%20%3C%2Fpredicate%3E%20%20%20%20%0A%20%20%3C%2Fsubject%3E%0A%3C%2Fresultset%3E", "id", "PortableControlApplication", "quality", "high", "bgcolor", "#869ca7", "name", "PortableControlApplication_map", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer", "wmode", "transparent" ); } 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_map" 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="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_map" align="middle" play="true" wmode="transparent" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object> </noscript> <div id="layersCanvas"></div> <div id="recordsCanvas"></div> </div> </td> </tr> </tbody> </table> <?php } ?> <?php if ($content_bottom): ?> <div id="content-bottom"> <?php print $content_bottom; ?> </div><!-- /content-bottom --> <?php endif; ?> </div><!-- /content-wrapper --> <?php if(FALSE): //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>