当前位置: 首页>>代码示例>>PHP>>正文


PHP Zikula_View::getTplVar方法代码示例

本文整理汇总了PHP中Zikula_View::getTplVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Zikula_View::getTplVar方法的具体用法?PHP Zikula_View::getTplVar怎么用?PHP Zikula_View::getTplVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zikula_View的用法示例。


在下文中一共展示了Zikula_View::getTplVar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_array_pop

/**
 * Pop a field of an array and assign its value to a template variable.
 *
 * Available attributes:
 *  - array  (string) Name of the template array variable to process
 *  - field  (string) Name of the array field to assign then unset
 *  - unset  (bool)   Flag to specify if the field must be unset or not (default: true)
 *  - assign (string) Name of the assign variable to setup (optional)
 *
 * Example:
 *
 *  Having an $objarray in our template, we want to process its fields in different
 *  sections of the template, so we get the needed fields separately on the desired positions,
 *  clearing the array in the process.
 *
 *  For instance, the $hooks array resulted of notify the 'display_view' hooks, can be
 *  processed individually using this plugin:
 *
 *  <samp>{array_pop array='hooks' field='EZComments'}</samp>
 *  <samp>{array_pop array='hooks' field='EZComments' assign='comments'}</samp>
 *
 *  And display later the remaining ones with a foreach.
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the {@link Zikula_View} object.
 *
 * @return mixed False on failure, void if the value is assigned, or the value extracted itself.
 */
function smarty_function_array_pop($params, Zikula_View $view)
{
    if (!isset($params['array']) || !$params['array']) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'var')));
        return false;
    }
    if (!isset($params['field']) || !$params['field']) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'value')));
        return false;
    }
    $unset = isset($params['unset']) ? (bool) $params['unset'] : true;
    $value = null;
    $array = $view->getTplVar($params['array']);
    if ($array && isset($array[$params['field']])) {
        $value = $array[$params['field']];
        if ($unset) {
            unset($array[$params['field']]);
        }
        $view->assign($params['array'], $array);
    }
    if (isset($params['assign']) && $params['assign']) {
        $view->assign($params['assign'], $value);
    } else {
        return $value;
    }
}
开发者ID:planetenkiller,项目名称:core,代码行数:54,代码来源:function.array_pop.php

示例2: smarty_function_admincategorymenu

/**
 * Smarty function to display the category menu for admin links. This also adds the
 * navtabs.css to the page vars array for stylesheets.
 *
 * Admin
 * {admincategorymenu}
 *
 * @see          function.admincategorymenu.php::smarty_function_admincategorymenu()
 * @param        array       $params      All attributes passed to this function from the template
 * @param        \Zikula_View $view        Reference to the Zikula_View object
 * @return       string      the results of the module function
 */
function smarty_function_admincategorymenu($params, \Zikula_View $view)
{
    PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('ZikulaAdminModule'));
    $modinfo = ModUtil::getInfoFromName($view->getTplVar('toplevelmodule'));
    $acid = ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'getmodcategory', array('mid' => $modinfo['id']));
    $path = array('_controller' => 'ZikulaAdminModule:Admin:categorymenu', 'acid' => $acid);
    $subRequest = $view->getRequest()->duplicate(array(), null, $path);
    return $view->getContainer()->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST)->getContent();
}
开发者ID:Silwereth,项目名称:core,代码行数:21,代码来源:function.admincategorymenu.php

示例3: smarty_function_array_field

/**
 * Assign an array field to a variable or display it in the output.
 *
 * Available attributes:
 *  - array  (mixed)  Name of the template array variable or the array itself to process
 *  - field  (string) Name of the array field to assign
 *  - assign (string) Name of the assign variable to setup (optional)
 *
 * Example:
 *
 *  Having an $objarray in our template, we want to check if a field is set
 *  or extract one field on another var to process it apart.
 *
 *  For instance, we need the localized output of a category. We have the
 *  $category variable, and we pass the display_name to the plugin, to get the local name:
 *
 *  <samp>{array_field array=$category.display_name field=$lang assign='displayname'}</samp>
 *
 *  And if you need to be sure that the value is set, you must test it:
 *
 *  <samp>{if $displayname}</samp>
 *
 *  In the other hand, if you have a field that exists for sure, that is in the first level
 *  of the array and you want to extract it to another variable, you can do:
 *
 *  <samp>{array_field array='category' field='id' assign='cid'}</samp>
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the {@link Zikula_View} object.
 *
 * @return Void
 */
function smarty_function_array_field($params, Zikula_View $view)
{
    if (!isset($params['array'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'var')));
        return false;
    }
    if (!isset($params['field'])) {
        $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('assign_cache', 'value')));
        return false;
    }
    $array = is_array($params['array']) ? $params['array'] : $view->getTplVar($params['array']);
    $field = isset($params['field']) ? $params['field'] : '';
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $value = null;
    if ($field && is_array($array) && isset($array[$field])) {
        $value = $array[$field];
    }
    if ($assign) {
        $view->assign($params['assign'], $value);
    } else {
        return $value;
    }
}
开发者ID:planetenkiller,项目名称:core,代码行数:55,代码来源:function.array_field.php


注:本文中的Zikula_View::getTplVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。