本文整理汇总了PHP中tpl::load方法的典型用法代码示例。如果您正苦于以下问题:PHP tpl::load方法的具体用法?PHP tpl::load怎么用?PHP tpl::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpl
的用法示例。
在下文中一共展示了tpl::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: snippet
/**
* Embeds a snippet from the snippet folder
*
* @param string $file
* @param mixed $data array or object
* @param boolean $return
* @return string
*/
function snippet($file, $data = array(), $return = false)
{
if (is_object($data)) {
$data = array('item' => $data);
}
return tpl::load(c::get('root.snippets') . DS . $file . '.php', $data, $return);
}
示例2: snippet
/**
* Embeds a snippet from the snippet folder
*
* @param string $file
* @param mixed $data array or object
* @param boolean $return
* @return string
*/
function snippet($file, $data = array(), $return = false)
{
if (is_object($data)) {
$data = array('item' => $data);
}
return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.php', $data, $return);
}
示例3: render
/**
* Renders the snippet with the given data
*
* @param string $name
* @param array $data
* @param boolean $return
* @return string
*/
public function render($name, $data = [], $return = false)
{
if (is_object($data)) {
$data = ['item' => $data];
}
return tpl::load($this->kirby->registry->get('snippet', $name), $data, $return);
}
示例4: toHtml
public function toHtml()
{
$snippet = kirby()->roots()->snippets() . DS . 'webmentions' . DS . 'author.php';
if (!file_exists($snippet)) {
$snippet = dirname(__DIR__) . DS . 'snippets' . DS . 'author.php';
}
return tpl::load($snippet, array('author' => $this, 'mention' => $this->mention));
}
示例5: render
public function render()
{
$file = $this->_root . DS . str_replace('.', DS, $this->_file) . '.php';
if (!file_exists($file)) {
throw new Exception(l('view.error.invalid') . $file);
}
return tpl::load($file, $this->_data);
}
示例6: disqus
/**
* Disqus plugin
*
* @author Bastian Allgeier <bastian@getkirby.com>
* @version 2.0.0
*/
function disqus($shortname, $params = array())
{
$defaults = array('shortname' => $shortname, 'title' => page()->title(), 'identifier' => page()->disqussId()->or(page()->uri()), 'developer' => false, 'url' => url::current());
$options = array_merge($defaults, $params);
if (empty($options['shortname'])) {
throw new Exception('Please provide a disqus shortname');
}
$options['title'] = addcslashes($options['title'], "'");
$options['developer'] = $options['developer'] ? 'true' : 'false';
return tpl::load(__DIR__ . DS . 'template.php', $options);
}
示例7: getMonthBoard
public function getMonthBoard($month, $year)
{
// Calendar language
date_default_timezone_set('UTC');
$l = panel()->language();
setlocale(LC_ALL, $l . '_' . str::upper($l));
//setlocale(LC_ALL, 'us_US');
// Calendar stuff
$cal = new Calendarboard\calendar();
$currentMonth = $cal->month($year, $month);
return tpl::load(__DIR__ . DS . 'template.php', array('currentMonth' => $currentMonth, 'get_day_route_url' => purl($this->model(), 'field/' . $this->field()->name . '/calendarboard/get-day/'), 'calendarboard_url' => $this->model(), 'year_folder' => '/year-' . $year));
}
示例8: bgimage
/**
* imgsrc Plugin
*
* @author Marijn Tijhuis <marijn@studiodumbar.com>
* @author Jonathan van Wunnik <jonathan@studiodumbar.com.com>
* @version 1.0.0
*/
function bgimage($image = false, $options = array())
{
if (!$image) {
return;
}
// Default key values
$defaults = array('width' => null, 'height' => null, 'crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'quality' => c::get('thumbs.quality', 92), 'lazyload' => c::get('lazyload', false));
// Merge defaults and options
$options = array_merge($defaults, $options);
// Without resrc, maximize thumb width, for speedier loading of page!
if (c::get('resrc') == false) {
if (!isset($options['width'])) {
$thumbwidth = c::get('thumbs.width.default', 800);
} else {
$thumbwidth = $options['width'];
}
} else {
// If resrc is enabled, use original image width
$thumbwidth = $image->width();
}
// If no crop variable is defined *and* no cropratio
// is set, the crop variable is set to false
if (!isset($options['crop']) && !isset($options['cropratio'])) {
$options['crop'] = false;
}
// When a cropratio is set, calculate the ratio based height
if (isset($options['cropratio'])) {
// If cropratio is a fraction string (e.g. 1/2), convert to decimal
if (strpos($options['cropratio'], '/') !== false) {
list($numerator, $denominator) = str::split($options['cropratio'], '/');
$options['cropratio'] = $numerator / $denominator;
}
// Calculate new thumb height based on cropratio
$thumbheight = round($thumbwidth * $options['cropratio']);
// If a cropratio is set, the crop variable is always set to true
$options['crop'] = true;
// Manual set (crop)ratio
$ratio = $options['cropratio'];
} else {
// Intrinsic image's ratio
$ratio = 1 / $image->ratio();
// Max. height of image
$thumbheight = round($thumbwidth * $ratio);
}
// Create thumb url (create a new thumb object)
$options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'quality' => $options['quality'], 'crop' => $options['crop']), false);
// Add more values to options array, for use in template
$options['customwidth'] = $options['width'];
$options['customquality'] = $options['quality'];
$options['ratio'] = $ratio;
// Return template HTML
return tpl::load(__DIR__ . DS . 'template/bgimage.php', $options);
}
示例9: figure
/**
* Figure Plugin
*
* @author Marijn Tijhuis <marijn@studiodumbar.com>
* @author Jonathan van Wunnik <jonathan@studiodumbar.com.com>
* @version 1.0.0
*/
function figure($image = false, $options = array())
{
if (!$image) {
return;
}
// default key values
$defaults = array('crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'caption' => null, 'lazyload' => c::get('lazyload', false));
// merge defaults and options
$options = array_merge($defaults, $options);
// without resrc, maximize thumb width, for speedier loading of page!
if (c::get('resrc') == false) {
$thumbwidth = c::get('thumb.dev.width', 800);
} else {
// with resrc use maximum (original) image width
$thumbwidth = null;
}
// if no crop variable is defined *and* no cropratio
// is set, the crop variable is set to false
if (!isset($options['crop']) && !isset($options['cropratio'])) {
$options['crop'] = false;
}
// when a cropratio is set, calculate the ratio based height
if (isset($options['cropratio'])) {
// if resrc is enabled (and therefor $thumbwidth is not set (e.g. `null`),
// to use max width of image!), set thumbwidth to width of original image
if (!isset($thumbwidth)) {
$thumbwidth = $image->width();
}
// if cropratio is a fraction string (e.g. 1/2), convert to decimal
// if(!is_numeric($options['cropratio'])) {
if (strpos($options['cropratio'], '/') !== false) {
list($numerator, $denominator) = str::split($options['cropratio'], '/');
$options['cropratio'] = $numerator / $denominator;
}
// calculate new thumb height based on cropratio
$thumbheight = round($thumbwidth * $options['cropratio']);
// if a cropratio is set, the crop variable is always set to true
$options['crop'] = true;
} else {
$thumbheight = null;
// max height of image
}
// Create thumb url (create a new thumb object)
$options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'crop' => $options['crop']), false);
// Add image object to options array, for use in template
$options['image'] = $image;
// Return template HTML
return tpl::load(__DIR__ . DS . 'template.php', $options);
}
示例10: content
/**
* Generate field content markup
*
* @return string
*/
public function content()
{
$wrapper = new Brick('div');
$wrapper->addClass('subpagelist');
$children = $this->subpages();
// add pagination to the subpages
$limit = $this->limit() ? $this->limit() : 10000;
$children = $children->paginate($limit, array('page' => get('page')));
// use existing snippet to build the list
// @see panel/app/controllers/views/pages.php
$subpages = new Snippet('pages/sidebar/subpages', array('title' => l('pages.show.subpages.title'), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => !api::maxPages($this, $this->subpages()->max()), 'pagination' => $children->pagination()));
// use template with defined vars
$wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
return $wrapper;
}
示例11: snippet_detect
function snippet_detect($file, $data = array(), $return = false)
{
if (is_object($data)) {
$data = array('item' => $data);
}
// If the session variable is not found, set the default value (e.g 'mobile')
$device_class = s::get('device_class', 'mobile');
// Embed the device class specific snippet
if ($device_class == 'mobile') {
// Embed the mobile snippet (`mobile` is the default snippet, without the device specific `.postfix`, e.g. footer.php)
return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.php', $data, $return);
} else {
// Embed the device class specific snippet (e.g. `footer.desktop.php`)
return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.' . $device_class . '.php', $data, $return);
}
}
示例12: analytics
/**
* Analytics plugin for Kirby
*
* @author Authorless
* @version 1.0
*/
function analytics()
{
if (c::get('analytics', false) === false) {
return;
}
$id = c::get('analytics.id');
if ($id === null) {
return;
}
$anonymize = c::get('analytics.anonymize', false);
if (is_bool($anonymize) === false) {
$anonymize = false;
}
$templateData = compact('id', 'anonymize');
return tpl::load(__DIR__ . DS . 'template.php', $templateData);
}
示例13: content
/**
* Generate field content markup
*
* @return string
*/
public function content()
{
$wrapper = new Brick('div');
$wrapper->addClass('subpagelist');
$children = $this->subpages();
// add pagination to the subpages
$limit = $this->limit() ? $this->limit() : 10000;
$children = $children->paginated('sidebar');
$pagination = new Snippet('pagination', array('pagination' => $children->pagination(), 'nextUrl' => $children->pagination()->nextPageUrl(), 'prevUrl' => $children->pagination()->prevPageUrl()));
// use existing snippet to build the list
// @see /panel/app/src/panel/models/page/sidebar.php
$subpages = new Snippet('pages/sidebar/subpages', array('title' => $this->i18n($this->label), 'page' => $this->page(), 'subpages' => $children, 'addbutton' => $this->page->addButton(), 'pagination' => $pagination));
// use template with defined vars
$wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('subpages' => $subpages)));
return $wrapper;
}
示例14: render
/**
* Renders the template by page with the additional data
*
* @param Page|string $template
* @param array $data
* @param boolean $return
* @return string
*/
public function render($template, $data = [], $return = true)
{
if ($template instanceof Page) {
$page = $template;
$file = $page->templateFile();
$data = $this->data($page, $data);
} else {
$file = $template;
$data = $this->data(null, $data);
}
// check for an existing template
if (!file_exists($file)) {
throw new Exception('The template could not be found');
}
// merge and register the template data globally
tpl::$data = array_merge(tpl::$data, $data);
// load the template
return tpl::load($file, null, $return);
}
示例15: editForm
/**
* Render the edit comment form.
*
* @return string
*/
public function editForm()
{
return tpl::load(__DIR__ . DS . 'form.php', array('field' => $this));
}