本文整理汇总了PHP中WebPage::setTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP WebPage::setTemplate方法的具体用法?PHP WebPage::setTemplate怎么用?PHP WebPage::setTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage::setTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_page_load
<?php
require_once 'dotweb/class.webpage.php';
$web = new WebPage();
$controls = $web->setTemplate('./templates', 'table.html');
$web->setTitle('DotWeb: Table Example');
$web->executePage();
function on_page_load()
{
global $web, $controls;
$link = new HTMLAnchor('');
// data array that could also come from a textfile or a database
$data = array(array('Firefox', '0.9.2', 'Linux, Mac OS X and Windows', 'http://www.mozilla.org/products/firefox/'), array('Mozilla', '1.7.1', 'Linux, Mac OS X and Windows', 'http://www.mozilla.org/products/mozilla1.x'), array('Konqueror', '3.2.3', 'Linux', 'http://www.konqueror.org/'), array('Safari', '1.2', 'Mac OS X', 'http://www.apple.com/safari/'), array('Opera', '7.5', 'Linux, Mac OS X and Windows', 'http://www.opera.com/'));
// table caption and col headings
$controls['tblbrowsers']->setCaption('Modern Browsers');
$controls['tblbrowsers']->addHeaderRow(array('Browser', 'Version', 'Supported Operating Systems', 'Website'));
// fill the table with the array data
$i = 1;
foreach ($data as $cur) {
// convert url at the end of the array to a HTML link
$url = array_pop($cur);
$link->setHref($url);
$link->setText($cur[0]);
array_push($cur, $link->getCode());
$controls['tblbrowsers']->addRow($cur);
$row =& $controls['tblbrowsers']->getLastRow();
// use two different colors for the rows
if ($i % 2 == 0) {
$row->setClass('bgcolor1');
} else {
$row->setClass('bgcolor2');
示例2: on_page_load
<?php
require_once 'dotweb/class.webpage.php';
$web = new WebPage();
$controls = $web->setTemplate('./templates', 'form.html');
$web->setTitle('DotWeb: Form Example');
$web->executePage();
function on_page_load()
{
global $web, $controls;
init_page();
$web->printTemplate($controls);
}
function on_get_send()
{
global $web, $controls;
init_page();
if ($web->isFormValid()) {
// hide our input form and show the success message
// which are both in the same template
$controls['formpers']->hide();
$controls['areamsg']->show();
// show the submitted data in a short summary
$controls['spanfirstname']->setContent($controls['edtfirstname']->getSubmitValue());
$controls['spanlastname']->setContent($controls['edtlastname']->getSubmitValue());
$controls['spanemail']->setContent($controls['edtemail']->getSubmitValue());
$controls['spancountry']->setContent($controls['selcountry']->getSubmitValue());
// set the correct back link
$controls['aback']->setHref($_SERVER['PHP_SELF']);
}
$web->printTemplate($controls);