本文整理汇总了PHP中Smarty_Internal_Template::clear_assign方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::clear_assign方法的具体用法?PHP Smarty_Internal_Template::clear_assign怎么用?PHP Smarty_Internal_Template::clear_assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::clear_assign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_block_menuItem
/**
* Smarty block plugin, for generating page menu item
* This block must always be called in pageMenu block context
*
* @param array $params
* @param Smarty $smarty
* @param $repeat
*
* <code>
* {pageMenu id="menu"}
* {menuItem}
* {menuCaption}Click Me{/menuCaption}
* {menuAction}http://click.me.com{/menuAction}
* {/menuItem}
* {menuItem}
* {menuCaption}Another menu item{/menuCaption}
* {pageAction}alert('Somebody clicked on me too!'){/menuAction}
* {/menuItem}
* {/pageMenu}
* </code>
*
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_block_menuItem($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
if ($repeat) {
$smarty->clear_assign('menuCaption');
$smarty->clear_assign('menuAction');
$smarty->clear_assign('menuPageAction');
} else {
$item = new HtmlElement('a');
if ($smarty->getTemplateVars('menuAction')) {
$href = $smarty->getTemplateVars('menuAction');
} else {
if ($smarty->getTemplateVars('menuPageAction')) {
$onClick = $smarty->getTemplateVars('menuPageAction');
$href = '#';
$item->setAttribute('onClick', $onClick . '; return false;');
}
}
$item->setAttribute('href', $href);
// EXPERIMENTAL - set access key for menu item
$caption = $smarty->getTemplateVars('menuCaption');
if (FALSE != strpos($caption, '&&')) {
$p = strpos($caption, '&&');
$accessKey = substr($caption, $p + 2, 1);
$item->setAttribute('accessKey', $accessKey);
$caption = substr($caption, 0, $p + 3) . '</span>' . substr($caption, $p + 3);
$caption = substr($caption, 0, $p) . '<span class="accessKey">' . substr($caption, $p + 2);
}
$item->setContent($caption);
$smarty->append('pageMenuItems', $item->render());
}
}
示例2: smarty_block_pageMenu
/**
* Smarty block plugin, for generating page menus
*
* @param array $params
* @param Smarty $smarty
* @param $repeat
*
* <code>
* {pageMenu id="menu"}
* {menuItem}
* {menuCaption}Click Me{/menuCaption}
* {menuAction}http://click.me.com{/menuAction}
* {/menuItem}
* {menuItem}
* {menuCaption}Another menu item{/menuCaption}
* {pageAction}alert('Somebody clicked on me too!'){/menuAction}
* {/menuItem}
* {/pageMenu}
* </code>
*
* @return string Menu HTML code
* @package application.helper.smarty
* @author Integry Systems
*/
function smarty_block_pageMenu($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
if ($repeat) {
$smarty->clear_assign('pageMenuItems');
} else {
$items = $smarty->getTemplateVars('pageMenuItems');
$menuDiv = new HtmlElement('div');
$menuDiv->setAttribute('id', $params['id']);
$menuDiv->setAttribute('tabIndex', 1);
$menuDiv->setContent(implode(' | ', $items));
return $menuDiv->render();
}
}