https://github.com/mgrechanik/yii2-seo-categories
Active Record hierarchical SEO categories and tags for Yii2 framework
https://github.com/mgrechanik/yii2-seo-categories
Last synced: 4 months ago
JSON representation
Active Record hierarchical SEO categories and tags for Yii2 framework
- Host: GitHub
- URL: https://github.com/mgrechanik/yii2-seo-categories
- Owner: mgrechanik
- License: other
- Created: 2020-01-25T05:56:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-25T05:57:09.000Z (over 5 years ago)
- Last Synced: 2025-04-05T18:44:02.944Z (6 months ago)
- Language: PHP
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Active Record hierarchical SEO categories and tags for Yii2 framework
[Русская версия](docs/README_ru.md)
## Table of contents
* [Goal](#goal)
* [Demo](#demo)
* [Installing](#installing)
* [Module settings](#settings)---
## Goal
This extension gives you a **variation** of [categories module](https://github.com/mgrechanik/yii2-categories-and-tags),
in which the [opportunity](https://github.com/mgrechanik/yii2-categories-and-tags#custom-ar) to create any your own ```Active Record``` category models was given.We suggest that when creating pages at **frontend** to display associated content of the category (or tag)
we would need to manage SEO information of such category page.Respectively we add next fields to our SEO category ```Active Record``` model:
* ```name``` to name category
* ```title``` for content of `````` tag
* ```meta_description``` for value of ```content``` attribute of `````` tag
* ```meta_keywords``` for value of ```content``` attribute of `````` tag
* ```meta_other``` to inserting any other ```html``` meta tags you may need
* ```slug``` serves as a "slug", or tail, in the page address
> With all this in module's settings you may choose not to use ```meta_other```
> or ```slug``` fields and they will not appear in the web form of creating/editing SEO category
---
## Installing#### Installing through composer:
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).:
Either run
```
composer require --prefer-dist mgrechanik/yii2-seo-categories
```or add
```
"mgrechanik/yii2-seo-categories" : "~1.0.0"
```
to the require section of your `composer.json`#### Migrations
This extension comes with two migrations:
- the first creates SEO categories table with all indexes needed
- the second creates unique index for ```slug``` fieldYou can run both of them:
```
php yii migrate --migrationPath=@vendor/mgrechanik/yii2-seo-categories/src/console/migrations
```, or when you do not use ```slug``` field run only the first migration:
```
php yii migrate 1 --migrationPath=@vendor/mgrechanik/yii2-seo-categories/src/console/migrations
```#### Setting the module up
As was mentioned in the [basic categories module](https://github.com/mgrechanik/yii2-categories-and-tags#goal),
this module follows the approach of *universal module*, and since it gives you
only **backend** pages when you set it up into your application specify the next ```mode``` :
```php
'modules' => [
'seocategory' => [
'class' => 'mgrechanik\yii2seocategory\Module',
'mode' => 'backend',
// Other module settings
],
// ...
],
```Done. When you access ```/seocategory``` page you will see all your SEO categories in a form of tree.
---
## Module settings
[Setting up](#setup) the module into application, along with all properties of the [base categories module](https://github.com/mgrechanik/yii2-categories-and-tags#settings), we can use it's next properties:
#### ```$useMetaOtherField = false```
- Whether to use ```other meta tags``` field#### ```$useSlugField = true```
- Whether to use ```slug``` field. It is supposed to be unique#### ```$slugPattern```
- When we use previous field in this property we set up regular expression of expected symbols#### ```$showTitleColumnAtIndexPage = true```
- Whether to display ```title``` field in the categories list grid#### ```$showSlugColumnAtIndexPage = false```
- Whether to display ```slug``` field in the categories list grid