本文整理汇总了PHP中CController::beforeRender方法的典型用法代码示例。如果您正苦于以下问题:PHP CController::beforeRender方法的具体用法?PHP CController::beforeRender怎么用?PHP CController::beforeRender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CController
的用法示例。
在下文中一共展示了CController::beforeRender方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
public function beforeRender($view)
{
parent::beforeRender($view);
Yii::app()->clientScript->registerCoreScript('jquery');
$this->includeScriptFile();
return true;
}
示例2: beforeRender
protected function beforeRender($view)
{
parent::beforeRender($view);
$titles = $this->pageTitles;
$titles[] = Config::model()->get('title');
$this->setPageTitle(implode(' - ', $titles));
return true;
}
示例3: beforeRender
protected function beforeRender($view)
{
static $calledBeforeRender = false;
if (!$calledBeforeRender) {
$calledBeforeRender = true;
// I want this code here because ajax requests shouldn't get this header and meta tags
// so beforerender might be the best place
header('Content-type: text/html; charset=utf-8');
Yii::app()->clientScript->registerMetaTag(Yii::app()->language, 'language');
if (!$this->canonicalUrl) {
if ($this->route == 'page/categorypage/multi' && isset($_GET['multi'])) {
$_GET['multi'] = str_replace(',', ' ', $_GET['multi']);
}
$this->canonicalUrl = $this->createAbsoluteUrl('/' . $this->route, $_GET);
}
$this->canonicalUrl = false;
}
return parent::beforeRender($view);
}
示例4: beforeRender
protected function beforeRender($view)
{
$this->pageTitle = Yii::app()->params['title'];
if (is_object($this->_model)) {
if (isset($this->_model->title) && $this->_model->title) {
$this->pageTitle .= ' - ' . $this->_model->title;
$this->pageCaption = $this->_model->title;
}
if (isset($this->_model->description) && $this->_model->description) {
$this->pageDescription = $this->_model->description;
}
if (isset($this->_model->keywords) && $this->_model->keywords) {
$this->pageKeywords = $this->_model->keywords;
}
}
if (!$this->pageDescription) {
$this->pageDescription = Yii::app()->params['description'];
}
if (!$this->pageKeywords) {
$this->pageKeywords = Yii::app()->params['keywords'];
}
return parent::beforeRender($view);
}
示例5: beforeRender
/**
* Meta description and keyword generate
*/
protected function beforeRender($view)
{
$model = OmmuSettings::model()->findByPk(1, array('select' => 'site_title, site_keywords, site_description'));
if (!Yii::app()->request->isAjaxRequest) {
if (parent::beforeRender($view)) {
// Ommu custom description and keyword
if (!empty($this->pageDescription)) {
$description = $this->pageDescription;
} else {
$description = $model->site_description;
}
Yii::app()->clientScript->registerMetaTag(Utility::hardDecode($description), 'description');
if (!empty($this->pageMeta)) {
$keywords = $model->site_keywords . ',' . $this->pageMeta;
} else {
$keywords = $model->site_keywords;
}
Yii::app()->clientScript->registerMetaTag(Utility::hardDecode($keywords), 'keywords');
/**
* Facebook open graph and all custom metatags
* @title
* @description
* @image
*/
// title
Yii::app()->meta->googlePlusTags['name'] = Yii::app()->meta->facebookTags['og:title'] = Yii::app()->meta->twitterTags['twitter:title'] = CHtml::encode($this->pageTitle) . ' | ' . $model->site_title;
// description
Yii::app()->meta->googlePlusTags['description'] = Yii::app()->meta->facebookTags['og:description'] = Yii::app()->meta->twitterTags['twitter:description'] = ucfirst(strtolower($description));
// image
if (!empty($this->pageImage)) {
Yii::app()->meta->facebookTags['og:image'] = Yii::app()->meta->googlePlusTags['image'] = Yii::app()->meta->twitterTags['twitter:image:src'] = Utility::getProtocol() . '://' . Yii::app()->request->serverName . $this->pageImage;
}
// language
$this->lang = Utility::getLanguage();
Yii::app()->setLanguage($this->lang);
}
} else {
$this->pageDescription = $this->pageDescription != '' ? ucfirst(strtolower($this->pageDescription)) : $model->site_description;
$this->pageMeta = $this->pageMeta != '' ? $model->site_keywords . ', ' . $this->pageMeta : $model->site_keywords;
}
$this->pageTitle = $this->pageTitle != '' ? $this->pageTitle : 'Titlenya Lupa..';
return true;
}
示例6: beforeRender
/**
* @param string $view the view to be rendered
* @return bool
*/
public function beforeRender($view)
{
if (!parent::beforeRender($view)) {
return false;
}
if ($this->id != 'default' || $this->action->id != 'index') {
$this->addBreadcrumb($this->module->name, array('/' . $this->module->id));
}
return true;
}
示例7: beforeRender
protected function beforeRender($view)
{
$this->initBreadcrumbsAndMenu();
return parent::beforeRender($view);
}
示例8: beforeRender
public function beforeRender($view)
{
if (!parent::beforeRender($view)) {
return false;
}
$this->addBreadcrumb($this->id, array('/' . $this->action->id));
return true;
}
示例9: beforeRender
/**
*
* @param type $view
* @return type
*/
protected function beforeRender($view)
{
$this->initLayout();
$cs = Yii::app()->clientScript;
if ($this->getEdit_mode()) {
$this->widget('ext.tinymce.TinymceWidget');
$cs = Yii::app()->clientScript;
$cs->registerScriptFile($this->getBaseAssetsUrl() . '/js/edit_mode.js');
$cs->registerCssFile($this->getBaseAssetsUrl() . '/css/edit_mode.css');
}
$cs->registerMetaTag('CORNER CMS ' . Yii::app()->version, 'author');
$cs->registerMetaTag($this->pageDescription !== null ? $this->pageDescription : '', 'description');
$cs->registerMetaTag($this->pageKeywords !== null ? $this->pageKeywords : '', 'keywords');
$cs->registerScript('app', "\r\n app.token = '" . Yii::app()->request->csrfToken . "';\r\n app.language = '" . Yii::app()->language . "';\r\n app.message = {\r\n save:'" . Yii::t('app', 'SAVE') . "',\r\n cancel:'" . Yii::t('app', 'CANCEL') . "',\r\n error:{\r\n 404:'" . Yii::t('error', '404') . "'\r\n },\r\n }\r\n ", CClientScript::POS_HEAD);
return parent::beforeRender($view);
}
示例10: beforeRender
public function beforeRender($view)
{
parent::beforeRender($view);
$this->includeScriptFile();
return true;
}
示例11: beforeRender
protected function beforeRender($view)
{
$return = parent::beforeRender($view);
Yii::app()->googleAnalytics->render();
return $return;
}
示例12: beforeRender
/**
* Initialize toastr.js message on beforeRender
* @param string $view view
* @return boolean render success status
*/
public function beforeRender($view)
{
if (UserWeb::instance()->hasMessage()) {
$this->renderJS(array(), array('message' => array('status' => UserWeb::instance()->getMessageStatus(), 'content' => UserWeb::instance()->getMessageContent())));
}
return parent::beforeRender($view);
}
示例13: beforeRender
/**
* This method is invoked at the beginning of {@link CController::render()}.
* You may override this method to do some preprocessing when rendering a view.
* @param string $view the view to be rendered
* @return boolean whether the view should be rendered.
*/
protected function beforeRender($view)
{
SourceBans::app()->trigger('app.beforeRender', new CEvent($this, array('view' => $view)));
return parent::beforeRender($view);
}
示例14: beforeRender
public function beforeRender($view)
{
//some SEO stuffs here
if ($this->pageRobotsIndex == false) {
Yii::app()->clientScript->registerMetaTag('noindex', 'robots');
}
if (Settings::get('SEO', 'enable_meta_description_for_all_pages')) {
$meta_description = Settings::get('SEO', 'meta_description');
if (!empty($meta_description)) {
Yii::app()->clientScript->registerMetaTag($meta_description, 'description');
}
}
if (Settings::get('SEO', 'enable_meta_keywords')) {
if (empty($this->pageKeywords)) {
$this->pageKeywords = Settings::get('SEO', 'meta_keywords');
}
}
if (Settings::get('SEO', 'enable_open_graph_meta_tags')) {
$site_name = Awecms::getSiteName();
if (!empty($site_name)) {
Yii::app()->clientScript->registerMetaTag($site_name, NULL, NULL, array('property' => 'og:site_name'));
}
if (!empty($this->pageTitle)) {
Yii::app()->clientScript->registerMetaTag($this->pageTitle, NULL, NULL, array('property' => 'og:title'));
}
$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
Yii::app()->clientScript->registerMetaTag($protocol . $_SERVER['HTTP_HOST'] . Yii::app()->request->requestUri, NULL, NULL, array('property' => 'og:url'));
if (!empty($meta_description)) {
Yii::app()->clientScript->registerMetaTag($meta_description, NULL, NULL, array('property' => 'og:description'));
}
}
if ($this->pageKeywords) {
Yii::app()->clientScript->registerMetaTag($this->pageKeywords, 'keywords');
}
Yii::app()->clientScript->registerMetaTag('AweCMS ' . Awecms::version, 'generator');
return parent::beforeRender($view);
}
示例15: beforeRender
public function beforeRender($view)
{
parent::beforeRender($view);
if (isset(Yii::app()->user->id)) {
$mUser = Users::model()->findByPk(Yii::app()->user->id);
if (is_null($mUser) || $mUser->status == STATUS_INACTIVE) {
Yii::app()->user->logout();
Yii::app()->controller->redirect(Yii::app()->createAbsoluteUrl('site/login'));
}
}
return true;
}