yii2-articles

Yii2 Articles to create, manage and delete items in a Yii2 site

  • 所有者: cinghie/yii2-articles
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Yii2 Articles

License
Latest Stable Version
Latest Release Date
Latest Commit
Total Downloads

Yii2 Articles to create, manage, and delete articles in a Yii2 site.

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require cinghie/yii2-articles "*"

or add

"cinghie/yii2-articles": "*"

Configuration

1. Images folder

Copy img folder to your webroot

2. Update yii2 articles database schema

Make sure that you have properly configured db application component.
Make sure that you have an user with id=1.
Run the following command:

$ php yii migrate/up --migrationPath=@vendor/cinghie/yii2-articles/migrations

3. Set configuration file

Set on your configuration file, in modules section

'modules' => [ 

	// Module Articles
	'articles' => [
		'class' => 'cinghie\articles\Articles',
		'userClass' => 'dektrium\user\models\User',
		
		// Select Languages allowed
		'languages' => [ 
			"it-IT" => "it-IT", 
			"en-GB" => "en-GB" 
		],			
		// Select Default Language  
		'languageAll' => 'it-IT',
		
		// Select Date Format
		'dateFormat' => 'd F Y',
		
		// Select Editor: no-editor, ckeditor, imperavi, markdown, tinymce
		'editor' => 'ckeditor',
		
		// Select Path To Upload Category Image
		'categoryImagePath' => '@webroot/img/articles/categories/',
		// Select URL To Upload Category Image
		'categoryImageURL'  => '@web/img/articles/categories/',
		// Select Path To Upload Category Thumb
		'categoryThumbPath' => '@webroot/img/articles/categories/thumb/',
		// Select URL To Upload Category Image
		'categoryThumbURL'  => '@web/img/articles/categories/thumb/',

		// Select Path To Upload Item Image
		'itemImagePath' => '@webroot/img/articles/items/',
		// Select URL To Upload Item Image
		'itemImageURL' => '@web/img/articles/items/',
		// Select Path To Upload Item Thumb
		'itemThumbPath' => '@webroot/img/articles/items/thumb/',
		// Select URL To Upload Item Thumb
		'itemThumbURL' => '@web/img/articles/items/thumb/',

		// Select Path To Upload Attachments
		'attachPath' => '@webroot/attachments/',
		// Select URL To Upload Attachment
		'attachURL' => '@web/img/articles/items/',
		// Select Image Types allowed
		'attachType' => ['jpg','jpeg','gif','png','csv','pdf','txt','doc','docs'],
		
		// Select Image Name: categoryname, original, casual
		'imageNameType' => 'categoryname',
		// Select Image Types allowed
		'imageType' => ['png','jpg','jpeg'],
		// Thumbnails Options
		'thumbOptions'  => [ 
			'small'  => ['quality' => 100, 'width' => 150, 'height' => 100],
			'medium' => ['quality' => 100, 'width' => 200, 'height' => 150],
			'large'  => ['quality' => 100, 'width' => 300, 'height' => 250],
			'extra'  => ['quality' => 100, 'width' => 400, 'height' => 350],
		],

		// Slugify Options
		$slugifyOptions = [
		    'separator' => '-',
		    'lowercase' => true,
		    'trim' => true,
		    'rulesets'  => [
		        'default'
		    ]
		],

		// Show Titles in the views
		'showTitles' => true,
		],	
	],
	
]

4. Other Configurations

To use easily this extension is strongly recommended install and config dektrium/yii2-user to manage user

Installation
Configuration

and dektrium/yii2-rbac to manage auth permission

Installation

5. Add your User as admin

INSERT INTO `PREFIX_auth_assignment` (`item_name`, `user_id`, `created_at`) VALUES
('admin', 'YUOR_USER_ID', 1451514052);

Override PREFIX_ with your tables prefix and YUOR_USER_ID with your user_id. For example:

INSERT INTO `auth_assignment` (`item_name`, `user_id`, `created_at`) VALUES
('admin', '1', 1451514052);

Advanced Template recommended configuration

URL Rules

'components' => [

    // Url Manager
    'urlManager' => [
	'class' => 'codemix\localeurls\UrlManager',
	// All languages including the default language
	'languages' => ['it', 'en'],
	// The default language is now treated like any other configured language
	'enableDefaultLanguageUrlCode' => true,
        // Disable index.php
        'showScriptName' => false,
        // Disable r= routes
        'enablePrettyUrl' => true,
        // Disable site/ from the URL
        'rules' => [
            '<alias:index, about, contact>' => 'site/<alias>',
	    '<id:\d+>/<alias:[A-Za-z0-9 -_.]+>' => 'articles/categories/view',
	    '<cat>/<id:\d+>/<alias:[A-Za-z0-9 -_.]+>' => 'articles/items/view',
	    '<tags>/<id:\d+>/<alias:[A-Za-z0-9 -_.]+>' => 'articles/tags/view'
        ],
     ],
     
],

Filters

If you have a Yii2 App Advanced (frontend/backend) you can exclude frontend actions

'modules' => [ 
	
	'articles' => [ 
		'class' => 'cinghie\articles\Articles',
		'as frontend' => 'cinghie\articles\filters\FrontendFilter',
	]
	
],

Overrides

Override controller example, on modules config

'modules' => [ 
	
	'articles' => [ 
		'class' => 'cinghie\articles\Articles',
		'controllerMap' => [
			'items' => 'app\controllers\MyItemsController'
		]
	]
	
],

Override models example, on modules config

'modules' => [ 
	
	'articles' => [ 
		'class' => 'cinghie\articles\Articles',
		'modelMap' => [
			'Items' => 'app\models\MyItemsModel'
		]
	]
	
],

Override view example, on components config

'components' => [ 

	'view' => [
		'theme' => [
			'pathMap' => [
				'@cinghie/articles/views/items' => '@app/views/articles/items',
			],
		],
	],
	
],

Override examples can be found on overrides folder

Users Auth

Articles Permissions, create, publish, update, delete, index, view, :---------:, :------:, :-------:, :------:, :------:, :-----:, :----:, admin, yes, all, all, all, yes, yes, editor, yes, all, all, his, yes, yes, publisher, yes, his, his, no, his, yes, author, yes, no, his, no, his, yes, ### Categories Permissions, create, publish, update, delete, index, view, :---------:, :------:, :-------:, :------:, :------:, :-----:, :----:, admin, yes, yes, yes, yes, yes, yes, editor, yes, no, yes, no, yes, yes, publisher, no, no, no, no, yes, yes, author, no, no, no, no, yes, yes, ### Tags Permissions, create, publish, update, index, delete, :---------:, :------:, :-------:, :------:, :------:, :------:, admin, yes, yes, yes, yes, yes, editor, yes, yes, yes, yes, yes, publisher, yes, yes, yes, yes, no, author, yes, no, no, no, no, ### Users Types

The migrations add to the database 4 types of users:

主要指標

概覽
名稱與所有者cinghie/yii2-articles
主編程語言PHP
編程語言PHP (語言數: 2)
平台
許可證
所有者活动
創建於2014-04-27 10:38:21
推送於2023-04-06 08:08:16
最后一次提交2023-04-06 10:08:16
發布數13
最新版本名稱0.6.6 (發布於 )
第一版名稱v0.2.5 (發布於 )
用户参与
星數33
關注者數8
派生數19
提交數564
已啟用問題?
問題數32
打開的問題數7
拉請求數1
打開的拉請求數0
關閉的拉請求數6
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?