despark/igni-seo

Igni CMS SEO 包

v1.4.1 2018-02-07 15:12 UTC

This package is auto-updated.

Last update: 2024-09-19 13:41:16 UTC


README

Latest Stable Version

Despark 为 Laravel 5.3|5.4|5.5 开发的 igniCMS SEO 模块

安装

  1. 运行 composer require despark/igni-seo

  2. config/app.php 中,在 application service providers 之前添加 igniCMS SEO 模块服务提供者,如下所示 (Laravel 5.5 可选)

示例

 ...
  /*
  * igniCMS Service Providers
  */
  Despark\Cms\Seo\Providers\IgniSeoServiceProvider::class,
  /*
  * Package Service Providers...
  */
  Laravel\Tinker\TinkerServiceProvider::class,
 ...
  1. 运行 php artisan vendor:publish --provider="Despark\Cms\Seo\Providers\IgniSeoServiceProvider"。如果您使用的是 Laravel 5.3|5.4,将 --provider 替换为 --class

  2. 运行 php artisan migrate 将我们的 SEO 表添加到数据库。

  3. 在您的实体文件中,在 adminFormsField 中添加以下代码

   'content' => [
      'type' => 'wysiwyg',
      'label' => 'Content',
    ],
    'readability' => [
      'type' => 'readability',
      'for' => 'content', // This field is optional. Use it only if your column, that is going to be checked for readability, is not called content
      'editorPosition' => 0, // The position of the desired editor, if you have more than one wysiwygs
     ],
    'seo' => [
      'type' => 'seo',
      'routeName' => 'articles.show',
      'meta_title_field' => 'title', // This field is optional. Use it only if your column, which is going to be checked is not called title
     ],
  1. 将我们的 Traits 和 Interfaces 添加到您的 Model 中。
use Despark\Cms\Admin\Interfaces\UploadImageInterface;
use Despark\Cms\Admin\Traits\AdminImage;
use Despark\Cms\Models\AdminModel;
use Despark\Cms\Seo\Contracts\Seoable;
use Despark\Cms\Seo\Traits\HasSeo;

class Article extends AdminModel implements Seoable, UploadImageInterface
{
    use HasSeo;
    use AdminImage;

    protected $table = 'articles';

    protected $fillable = [
        'title',
        'slug',
        'content',
    ];

    protected $rules = [
        'title' => 'required',
        'slug' => 'required',
        'content' => 'required',
    ];

    protected $identifier = 'article';
}

获取您的 SEO 数据

  $seoData = $model->seo;

版权和许可证

igniCMS 是由 Despark 为 Laravel 框架编写的,并采用 MIT 许可证发布。有关详细信息,请参阅 LICENSE 文件。