当前位置: 首页>>代码示例>>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;未经允许,请勿转载。