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


PHP View::setLayout方法代码示例

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


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

示例1: boot

 /**
  * @param Event $event
  * @param Application $application
  * @return mixed
  */
 public function boot(Event $event, Application $application)
 {
     $config = $application->getConfig()->application;
     if (isset($config->view) && $config->view !== false) {
         $view = new View();
         $view->setViewsDir($config->view->viewsDir);
         $view->setLayoutsDir($config->view->layoutsDir);
         $view->setLayout($config->view->layout);
         $application->getDI()->setShared('view', $view);
     }
 }
开发者ID:vegas-cmf,项目名称:mvc,代码行数:16,代码来源:Boot.php

示例2: registerServices

 /**
  * Register specific services for the module
  */
 function registerServices(\Phalcon\DiInterface $di)
 {
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace('Modules\\Frontend\\Controllers');
         return $dispatcher;
     });
     $config = $di->getShared('config');
     $di->set('view', function () use($config, $di) {
         $view = new View();
         $router = $di->getShared('router');
         /*
          * @todo 给layouts等目录统一变量
          * */
         $view->setViewsDir(__DIR__ . '/views/');
         $view->setLayoutsDir('/../../../layouts/');
         // 多模块的话, 可能会有多个风格,所以需要切换layout,这里的Path是根据当前module的Path向上走的
         $view->setLayout('index');
         $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
             return $volt;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     }, true);
 }
开发者ID:justforleo,项目名称:phalcon-cmf,代码行数:30,代码来源:Module.php

示例3: setView

 private function setView()
 {
     $view = new View();
     $view->setViewsDir($this->config->application->viewsDir);
     $view->setLayoutsDir('layouts/');
     $view->setLayout('index');
     $view->registerEngines(['.volt' => $this->setVolt($view), '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php']);
     return $view;
 }
开发者ID:xsat,项目名称:www.test.com,代码行数:9,代码来源:MainApplication.php

示例4: render

 /**
  * @param string $layout
  *
  * @return string
  */
 public function render($layout = 'edit')
 {
     $column = $this->_params->getParam('name');
     $prefix = $this->_params->getParam('source');
     $fieldId = ($prefix ? $prefix . '_' : '') . $column;
     $fieldName = $prefix ? $prefix . '[' . $column . ']' : $column;
     $defaultParams = $this->_params->getParams();
     unset($defaultParams['name']);
     $tagParams = array_merge([$fieldName], $this->_params->getParam('tag', []), ['value' => $this->getValue(), 'id' => $fieldId] + $defaultParams);
     $this->_params->setParam('id', $fieldId);
     // все параметры уже добавлены, в общем списке они не нужны
     unset($tagParams['tag']);
     $tagParams['class'] = isset($tagParams['class']) ? $tagParams['class'] . ' form-control' : 'form-control';
     $layout = $this->_params->getParam('options.layout', $layout);
     $this->beforeRender($tagParams);
     $this->_view->setLayout($layout);
     $this->_view->setVars(['field' => $this, 'model' => $this->_model, 'params' => $this->_params, 'tag' => $tagParams]);
     return $this->_view->getRender($this->getLayoutDir($layout), $layout);
 }
开发者ID:moaljazaery,项目名称:phalcon-module-admin,代码行数:24,代码来源:Field.php

示例5: function

});
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
}, true);
/**
 * Setting up the view component
 */
$di->set('view', function () use($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    $view->setLayout('default');
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
}, true);
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di->set('db', function () use($config) {
    return new DbAdapter(array('host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname));
});
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
开发者ID:magnxpyr,项目名称:phalcon-webtools,代码行数:31,代码来源:services.php

示例6: testOverrideLayout

 public function testOverrideLayout()
 {
     $view = new Phalcon\Mvc\View();
     $view->setViewsDir('unit-tests/views/');
     //Override controller layout
     $view->start();
     $view->setLayout('test6');
     $view->render('test3', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Well, this is the view content: here.</html>' . PHP_EOL);
 }
开发者ID:racklin,项目名称:cphalcon,代码行数:11,代码来源:ViewTest.php

示例7: function

/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->set('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Start the session the first time some component request the session service
 */
$di->set('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set('view', function () use($config, $di) {
    $view = new View();
    $router = $di->getShared('router');
    /*
     * @todo 给layouts等目录统一变量
     * */
    $view->setViewsDir(__DIR__ . '/views/');
    $view->setLayoutsDir('/../../../layouts/');
    // 多模块的话, 可能会有多个风格,所以需要切换layout,这里的Path是根据当前module的Path向上走的
    $view->setLayout('adminCommon');
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
}, true);
开发者ID:justforleo,项目名称:phalcon-cmf,代码行数:31,代码来源:services.php

示例8: testLayoutAndPick

 public function testLayoutAndPick()
 {
     $view = new View();
     $view->setViewsDir('unit-tests/views/');
     // Pick string
     $view->start();
     $view->setLayout('test6');
     $view->pick('test3/other');
     $view->render('test3', 'another');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Well, this is the view content: here.</html>' . PHP_EOL);
     // Pick array
     $view->start();
     $view->setLayout('test6');
     $view->pick(array('test3/other'));
     $view->render('test3', 'another');
     $view->finish();
     $this->assertEquals($view->getContent(), '<html>Well, this is the view content: here.</html>' . PHP_EOL);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:19,代码来源:ViewTest.php

示例9: testLayoutAndPick

 /**
  * Test using different layout and pick
  *
  * @author Andres Gutierrez <andres@phalconphp.com>
  * @since  2013-01-07
  */
 public function testLayoutAndPick()
 {
     $this->specify('Using different layout and pick does not work as expected', function () {
         $view = new View();
         $view->setDI(Di::getDefault());
         $view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
         $view->start();
         $view->setLayout('test6');
         $view->pick('test3/other');
         $view->render('test3', 'another');
         $view->finish();
         expect($view->getContent())->equals("<html>Well, this is the view content: here.</html>\n");
         $view->start();
         $view->setLayout('test6');
         $view->pick(['test3/other']);
         $view->render('test3', 'another');
         $view->finish();
         expect($view->getContent())->equals("<html>Well, this is the view content: here.</html>\n");
     });
 }
开发者ID:phalcon,项目名称:cphalcon,代码行数:26,代码来源:ViewTest.php


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