本文整理汇总了PHP中Smarty::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::fetch方法的具体用法?PHP Smarty::fetch怎么用?PHP Smarty::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(array $data, $template)
{
foreach ($data as $name => $param) {
$this->_engine->assign($name, $param);
}
return $this->_engine->fetch($template);
}
示例2: getFooter
/**
* Returns the template's HTML footer
*
* @return string HTML footer
*/
public function getFooter()
{
$shop_address = $this->getShopAddress();
$id_shop = (int) $this->shop->id;
$this->smarty->assign(array('available_in_your_account' => $this->available_in_your_account, 'shop_address' => $shop_address, 'shop_fax' => Configuration::get('PS_SHOP_FAX', null, null, $id_shop), 'shop_phone' => Configuration::get('PS_SHOP_PHONE', null, null, $id_shop), 'shop_email' => Configuration::get('PS_SHOP_EMAIL', null, null, $id_shop), 'free_text' => Configuration::get('PS_INVOICE_FREE_TEXT', (int) Context::getContext()->language->id, null, $id_shop)));
return $this->smarty->fetch($this->getTemplate('footer'));
}
示例3: send
function send($id)
{
$form = is_array($id) ? $id : get($id);
$results = results($id);
if (!$results) {
return false;
}
if (!is_array($form['template']) || !strlen($form['template']['recipient'])) {
return false;
}
$smarty = new \Smarty();
$smarty->compile_check = true;
$smarty->debugging = false;
foreach ($results as $nm => $val) {
$smarty->assign($nm, $val);
}
$mail = new \PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->Subject = $smarty->fetch('string:' . $form['template']['subject']);
$addresses = explode(',', $form['template']['recipient']);
foreach ($addresses as $a) {
$mail->AddAddress(trim($a));
}
$mail->MsgHTML($smarty->fetch('string:' . $form['template']['body']));
return $mail->Send();
}
示例4: render
/**
* Renders a template using the provided data.
*
* @param string $template_slug
* @param array $data
*/
public function render($template_slug, array $data = array())
{
if (!empty($data)) {
array_walk($data, array($this, 'assign_template_var'));
}
$template_slug = preg_match('/\\.tpl$/', $template_slug) ? $template_slug : $template_slug . '.tpl';
return $this->smarty->fetch($template_slug);
}
示例5: it_should_call_display_method_on_smarty
/**
* @test
* it should call display method on Smarty
*/
public function it_should_call_display_method_on_smarty()
{
$sut = $this->make_instance();
$this->smarty->assign('key1', 'value1')->shouldBeCalled();
$this->smarty->assign('key2', 'value2')->shouldBeCalled();
$this->smarty->fetch('some-template.tpl')->willReturn('foo');
$sut->render('some-template', ['key1' => 'value1', 'key2' => 'value2']);
}
示例6: getRender
/**
* template render output
*
* @return string template render output
* @throws SynergyException
*/
protected function getRender()
{
if (isset($this->templateFile)) {
$this->assignSmartyVariables();
$render = $this->loader->fetch($this->templateFile);
return $render;
} else {
throw new SynergyException(sprintf('Invalid call to %s without setting templateFile', __METHOD__));
}
}
示例7: setMessageFromTemplate
public function setMessageFromTemplate($file, $data)
{
$smarty = new \Smarty();
$vars = ['template_dir' => Config::get('path.templates') . 'mail/', 'compile_dir' => Config::get('path.cache') . 'smarty/', 'cache_dir' => Config::get('path.cache')];
foreach ($vars as $name => $value) {
$smarty->{$name} = $value;
}
foreach ($data as $key => $value) {
$smarty->assign($key, $value);
}
$smarty->assign('content', $smarty->fetch($file . '.html'));
$this->Body = $smarty->fetch('layout.html');
return $this;
}
示例8: get
public function get($file, $assigned_variables)
{
// First set all the variables
$this->assigned_variables = $assigned_variables;
// Load Smarty
$this->loadSmarty();
// Set the directory
$this->smartyInstance->setTemplateDir($this->directory);
// Then assign all variables
foreach ($this->assigned_variables as $key => $value) {
$this->smartyInstance->assign($key, $value);
}
// And finally, load the template
return $this->smartyInstance->fetch($file);
}
示例9: render
/**
* Processes a template and returns the output.
*
* @param string $name The template to process.
* @return string The output.
*/
public function render($name)
{
$this->addFlashMessenger('Info');
$this->addFlashMessenger('Success');
$this->addFlashMessenger('Error');
return $this->_smarty->fetch($name);
}
示例10: convert
/**
* Converts markdown into HTML
*
* @param string $content
* @param array $config . Options to configure MarkdownExtra and smarty
* - markdown: array for MarkdownExtra configuration parameters
* - smarty: array for SmartyPantsTypographer configuration parameters
* - custom: array for Custom configuration parameters
* @param int $smartyMode the SmartyPantsTypographer processing mode
*
* @return string
* @throws InvalidConfigException if module not set
*/
public static function convert($content, $config = [], $smartyMode = self::SMARTYPANTS_ATTR_LONG_EM_DASH_SHORT_EN)
{
$module = Config::initModule(Module::classname());
$output = $content;
if (strlen($output) > 0) {
$mdConfig = empty($config['markdown']) ? [] : $config['markdown'];
$output = static::process($content, $mdConfig);
if ($module->smartyPants) {
$smConfig = empty($config['smarty']) ? [] : $config['smarty'];
$smarty = new SmartyPants($smartyMode);
foreach ($smConfig as $name => $value) {
$smarty->{$name} = $value;
}
$output = $smarty->transform($output);
$cuConfig = empty($config['custom']) ? $module->customConversion : $config['custom'];
$output = static::customProcess($output, $cuConfig);
}
if (is_bool($module->smarty) && $module->smarty || (is_string($module->smarty) || is_callable($module->smarty)) && call_user_func($module->smarty, $module)) {
$smarty = new \Smarty();
if ($module->smartyYiiApp) {
$smarty->assign('app', Yii::$app);
}
if ($module->smartyYiiParams) {
$smarty->config_vars = Yii::$app->params;
}
$output = $smarty->fetch('string:' . $output, null, null, $module->smartyParams);
}
}
return $output;
}
示例11: smarty_function_mobile_access_object_comments
/**
* Render comments
*
* Parameters:
*
* - comments - comments that needs to be rendered
* - page - current_page
* - total_pages - total pages
* - counter - counter for comment #
* - url - base URL for link assembly
* - parent - parent object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_mobile_access_object_comments($params, &$smarty)
{
$url_params = '';
if (is_foreachable($params)) {
foreach ($params as $k => $v) {
if (strpos($k, 'url_param_') !== false && $v) {
$url_params .= '&' . substr($k, 10) . '=' . $v;
}
// if
}
// foreach
}
// if
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
$user = array_var($params, 'user');
if (!instance_of($user, 'User')) {
return new InvalidParamError('object', $user, '$user is expected to be an instance of User class', true);
}
// if
$page = array_var($params, 'page', 1);
$page = (int) array_var($_GET, 'page');
if ($page < 1) {
$page = 1;
}
// if
$counter = array_var($params, 'counter', 1);
$counter = ($page - 1) * $object->comments_per_page + $counter;
list($comments, $pagination) = $object->paginateComments($page, $object->comments_per_page, $user->getVisibility());
$smarty->assign(array("_mobile_access_comments_comments" => $comments, "_mobile_access_comments_paginator" => $pagination, "_mobile_access_comments_url" => mobile_access_module_get_view_url($object), "_mobile_access_comments_url_params" => $url_params, "_mobile_access_comments_counter" => $counter, "_mobile_access_comments_show_counter" => array_var($params, 'show_counter', true)));
return $smarty->fetch(get_template_path('_object_comments', null, MOBILE_ACCESS_MODULE));
}
示例12: fetch
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
if (!is_null($template) && is_string($template) && !preg_match('/^(\\/|[a-z]{2,}:)/i', $template)) {
$template = 'extendsall:' . $template;
}
return parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter);
}
示例13: Display
public function Display($file = false, $echo = true)
{
global $CMS, $DB, $USER;
$smarty = new Smarty();
//set cache and compile dir
$smarty->setCacheDir("./data/data__hoang_taka_com/cache/");
$smarty->setCompileDir("./data/data__hoang_taka_com/template_c/");
$smarty->force_compile = $this->force_compile;
$smarty->debugging = $this->debugging;
$smarty->caching = $this->caching;
$smarty->cache_lifetime = $this->cache_lifetime;
if ($file) {
//check template website use.
$file_dir = "themes/" . $file . ".tpl";
if (is_file($file_dir)) {
$smarty->assign($this->data);
if ($echo) {
return $smarty->display($file_dir);
} else {
return $smarty->fetch($file_dir);
}
} else {
echo "File: <b>{$file_dir}</b> is missing.";
}
}
}
示例14: display
public function display()
{
//Smarty engine/Smarty 引擎
require ROOT . '/pf_core/smarty/libs/Smarty.class.php';
$smarty = new Smarty();
$table_fields = $this->initSqlFields();
$smarty->assign('table_fields', $table_fields);
$data_list = $this->loadData();
foreach ($data_list as $k => $v) {
if ($data_list[$k]['products_image']) {
$data_list[$k]['products_image'] = '<img width="50" height="50" src="http://pandoraf.com/applications/pandoraf/templates/imgServer/thumb/list_grid/' . $v['products_image'] . '"/>';
}
}
$smarty->assign('data_list', $data_list);
if (0) {
$contents = $smarty->fetch($this->data_tpl);
$result = array();
$result['page'] = 1;
$result['total_page'] = 2;
$result['contents'] = $contents;
echo json_encode($result);
return;
}
$smarty->display('web/table.html');
exit;
}
示例15: render
/**
* Processes a template and returns the output.
*
* @param string $name The template to process.
* @return string The output.
*/
public function render($name, $cacheId = null)
{
/**
* Create temporary folder for Smarty's compilation and caching if they didn't exist
*/
/**
* Compilation folder
*/
if (!is_dir($this->getCompilePath())) {
if (ini_get('safe_mode')) {
throw new Exception('PHP SAFE MODE is ON. System can not create compile folder "' . $this->getCompilePath() . '". Please create it with 777 mode.');
} else {
mkdir($this->getCompilePath(), 0777, true);
}
} elseif (!is_writable($this->getCompilePath())) {
throw new Exception('Compile folder "' . $this->getCompilePath() . '" is not writable. Please change it to 777 mode.');
}
/**
* Caching folder
*/
if (!is_dir($this->getCachePath())) {
if (ini_get('safe_mode')) {
throw new Exception('PHP SAFE MODE is ON. System can not create compile folder: ' . $this->getCachePath() . '". Please create it with 777 mode.');
} else {
mkdir($this->getCachePath(), 0777, true);
}
} elseif (!is_writable($this->getCachePath())) {
throw new Exception('Compile folder "' . $this->getCachePath() . '" is not writable. Please change it to 777 mode.');
}
if (null == $cacheId) {
$cacheId = $this->cacheId;
}
return $this->smarty->fetch($name, $cacheId);
}