當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Slug::create方法代碼示例

本文整理匯總了PHP中Slug::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slug::create方法的具體用法?PHP Slug::create怎麽用?PHP Slug::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slug的用法示例。


在下文中一共展示了Slug::create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setNameField

 public function setNameField($data, $value)
 {
     if ($data->get(self::SLUG) == null) {
         $data->set(self::SLUG, Slug::create($value));
     }
     return $value;
 }
開發者ID:DavBfr,項目名稱:BlogMVC,代碼行數:7,代碼來源:PostsModel.class.php

示例2: actionUpdate

 public function actionUpdate($id)
 {
     $page = $this->loadModel($id);
     if (isset($_POST['Page'])) {
         if (Settings::get('SEO', 'slugs_enabled')) {
             if (isset($page->slug)) {
                 if (isset($page->slug->slug) && $_POST['Page']['slug'] != $page->slug->slug) {
                     if ($_POST['Page']['slug'] == '') {
                         $page->slug->delete();
                         $page->slug = NULL;
                     } else {
                         $page->slug->change($_POST['Page']['slug']);
                     }
                 }
             } else {
                 $page->slug = Slug::create($_POST['Page']['slug'], array('view', 'id' => $id));
                 $page->save();
             }
         }
         try {
             if ($page->save()) {
                 $this->redirect(array('view', 'id' => $page->id));
             }
         } catch (Exception $e) {
             $page->addError('', $e->getMessage());
         }
     }
     $this->render('update', array('page' => $page));
 }
開發者ID:awecode,項目名稱:awecms,代碼行數:29,代碼來源:PageController.php

示例3: boot

 /**
  * When the model boots, register a created event listener that will create a slug,
  * using the model's id as the salt value for the generation of thee slug.
  */
 public static function boot()
 {
     parent::boot();
     static::created(function ($model) {
         $model->slug = Slug::create($model->id);
         $model->save();
     });
 }
開發者ID:kamaroly,項目名稱:shift,代碼行數:12,代碼來源:Sluggable.php

示例4: afterSave

 public function afterSave($event)
 {
     //slug for pages are handled in PageController, to prevent infinite loop
     if (get_class($this->owner) == 'Page') {
         return;
     }
     $page = $this->owner->page;
     if (Settings::get('SEO', 'slugs_enabled') && isset($_POST['Page']['slug']) && $_POST['Page']['slug'] != '') {
         if ($this->owner->scenario == 'insert' || $this->owner->scenario == 'update' && !isset($page->slug)) {
             //get the page
             $page = Page::model()->findByPk($page->id);
             //save the slug
             $page->slug = Slug::create($_POST['Page']['slug'], array('view', 'id' => $this->owner->id));
             $page->save();
         }
     }
 }
開發者ID:awecode,項目名稱:awecms,代碼行數:17,代碼來源:PageBehavior.php


注:本文中的Slug::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。