artur / sitemap_generator_l5
基于模型的网站地图生成器
2.0.2
2022-07-13 09:44 UTC
README
基于模型的网站地图生成器 生成的网站地图将在 http(s)://yoursite.com/sitemap.xml 可用
执行
composer require "artur/sitemap_generator_l5":"1.*"
将 SitemapGeneratorServiceProvider 添加到 config/app.php 中的 ServiceProviders
Vis\SitemapGenerator\SitemapGeneratorServiceProvider::class,
发布网站地图配置
php artisan vendor:publish --provider="Vis\SitemapGenerator\SitemapGeneratorServiceProvider" --force
将您的 models\custom urls 添加到 config/app/config/sitemap-generator/sitemap.php 配置文件中
启用/禁用网站地图生成,如果禁用,则显示 404 错误
'is_enabled' => true,
启用/禁用在网站地图中的多语言链接
'is_multi_language' => true,
模型 简短示例,将使用默认选项
'models' => [ 'Tree', ],
完整示例,展示所有可能选项
'models' => [ 'Tree_1' => [ //If this param is set model name will be taken from here rather then from array key //This allows to have multiple request to single model without overriding results 'model' => "Tree", // Valid values are "always|hourly|daily|weekly|monthly|yearly|never" 'changefreq' => "daily", // Valid values range from 0.0 to 1.0. 'priority' => 0.7, // Method that will be called upon model to get Url of entity // Default(if removed) - "getUrl" or set your method name 'url_method' => "getUrl", // Optional property. Default(if removed) - "updated_at", set false to disable or set your field name 'lastmod_field' => "updated_at", // Optional property. Default(if removed) - "is_active", set false to disable or set your field name 'active_field' => "is_active", // Optional property. Allows to specify query, can be removed if not required 'additional_where' => [ 'template' => [ 'sign' => '!=', 'value' => 'main' ], ], ], ],
自定义链接 简短示例,将使用默认选项
'custom_links' => [ '/', ],
完整示例,展示所有可能选项
'custom_links' => [ '/' => [ //If this param is set url be taken from here rather then from array key 'url' => "/", // Valid values are "always|hourly|daily|weekly|monthly|yearly|never" 'changefreq' => "daily", // Valid values range from 0.0 to 1.0. 'priority' => 1, // Valid values is anything parsable by strtotime method 'lastmod' => "2017-02-20 13:32:09", ], ],