本文整理汇总了PHP中ViewFactory::make_view方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewFactory::make_view方法的具体用法?PHP ViewFactory::make_view怎么用?PHP ViewFactory::make_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewFactory
的用法示例。
在下文中一共展示了ViewFactory::make_view方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_view
function get_view($template)
{
return ViewFactory::make_view(strtolower($template));
}
示例2: render_partial
function render_partial($action, $object = false, $collect = false, $controller = false)
{
#if the controller is an array, use it and ignore the rest
if (is_array($action)) {
if (array_key_exists('object', $action)) {
$object = $action['object'];
}
if (array_key_exists('collect', $action)) {
$collect = $action['collect'];
}
if (array_key_exists('controller', $action)) {
$controller = $action['controller'];
}
if (array_key_exists('action', $action)) {
$action = $action['action'];
}
} else {
if ($controller == false) {
$controller = params('controller');
}
}
# set the template and object name
$slashloc = strrpos($action, '/');
if ($slashloc !== false) {
$objectname = substr($action, $slashloc + 1);
if ($action[0] == '/') {
$template = substr(substr($action, 0, $slashloc) . '/_' . $objectname, 1);
} else {
$template = url_name($controller) . '/' . substr($action, 0, $slashloc) . '/_' . $objectname;
}
} else {
$template = url_name($controller) . '/_' . $action;
$objectname = $action;
}
$view = ViewFactory::make_view($template);
# include the helpers
if (file_exists(PROJECT_ROOT . '/app/helpers/app.php')) {
include_once PROJECT_ROOT . '/app/helpers/app.php';
}
if (file_exists(PROJECT_ROOT . '/app/helpers/' . $controller . '.php')) {
include_once PROJECT_ROOT . '/app/helpers/' . $controller . '.php';
}
# if it's a collection, call it for each item in the obj
$objectname = var_name(class_name($objectname));
if ($collect === true) {
foreach ($object as $k => $v) {
echo $view->parse_partial($objectname, $v);
}
} else {
echo $view->parse_partial($objectname, $object);
}
}