README.md 4.26 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
8
9
# Amos News

News management.

### Installation
You need to require this package and enable the module in your configuration.

add to composer requirements in composer.json
```
Aster's avatar
Aster committed
10
"arter/amos-news": "dev-master",
Marcello Pivanti's avatar
Marcello Pivanti committed
11
12
13
14
```

or run command bash:
```bash
Aster's avatar
Aster committed
15
composer require "arter/amos-news:dev-master"
Marcello Pivanti's avatar
Marcello Pivanti committed
16
17
18
19
20
```

Enable the News modules in modules-amos.php, add :
```php
 'news' => [
Aster's avatar
Aster committed
21
	'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
22
23
24
25
26
27
 ],

```

add news migrations to console modules (console/config/migrations-amos.php):
```
Aster's avatar
Aster committed
28
'@vendor/arter/amos-news/src/migrations'
Marcello Pivanti's avatar
Marcello Pivanti committed
29
30
31
32
33
```

If a frontend or a public site are used in your project and news need to be visible outside backend, enable form/wizard fields to allow publication in frontend/home page with params:
```php
'news' => [
Aster's avatar
Aster committed
34
        'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        'params' => [
            'site_publish_enabled' => true,
            'site_featured_enabled' => true
        ]
    ],
```


The content is suitable to be used with cwh content management.
To do so:
- Activate cwh plugin
- Open cwh configuration wizard (admin privilege is required) url: <yourPlatformurl>/cwh/configuration/wizard
- search for news in content configuration section
- edit configuration of news and save

Aster's avatar
Aster committed
50
51
If tags are needed enable this module in "modules-amos.php" (backend/config folder in main project) in tag section.
After that, enable the trees in tag manager.
Marcello Pivanti's avatar
Marcello Pivanti committed
52

Aster's avatar
Aster committed
53
54
If platform uses report and/or comments and you want to enable News to be commented/to report a content, 
add the model to the configuration in modules-amos.php:
Marcello Pivanti's avatar
Marcello Pivanti committed
55
56
57
58
59

for reports: 

```
 'report' => [
Aster's avatar
Aster committed
60
     'class' => 'arter\amos\report\AmosReport',
Marcello Pivanti's avatar
Marcello Pivanti committed
61
62
63
     'modelsEnabled' => [
        .
        .
Aster's avatar
Aster committed
64
        'arter\amos\news\models\News', //line to add
Marcello Pivanti's avatar
Marcello Pivanti committed
65
66
67
68
69
70
71
72
73
74
75
        .
        .
     ]
     ],

```

for comments:

```
  'comments' => [
Aster's avatar
Aster committed
76
    'class' => 'arter\amos\comments\AmosComments',
Marcello Pivanti's avatar
Marcello Pivanti committed
77
78
79
    'modelsEnabled' => [
        .
        .
Aster's avatar
Aster committed
80
        'arter\amos\news\models\News', //line to add
Marcello Pivanti's avatar
Marcello Pivanti committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        .
        .
 	],
  ],
```


### Configurable fields

Here the list of configurable fields, properties of module AmosNews.
If some property default is not suitable for your project, you can configure it in module, eg: 

```php
 'news' => [
Aster's avatar
Aster committed
95
	'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
96
97
98
99
100
101
102
103
104
105
106
107
	'validatePublicationDate' => false, //changed property (default was true)
 ],
```

* **validatePublicationDate** - boolean, default = true  
If this attribute is true the validation of the publication date is active.  
By default, you can ONLY validate news with publication_date greater or equal than TODAY.  
Set to false to allow validation for news with publication_date less than TODAY.

* **filterCategoriesByRole** - boolean, default = false   
If true, enables category role check via table news_category_roles_mm.  
By default news category are available to all users.  
Aster's avatar
Aster committed
108
109
In case categories are in association with rbac roles, populate table 'news_category_roles_mm' 
and set to true the Module property filterCategoriesByRole in configurations:
Marcello Pivanti's avatar
Marcello Pivanti committed
110
111
112

```php
    'news' => [
Aster's avatar
Aster committed
113
      'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
114
115
116
117
118
119
120
121
122
123
124
125
      'filterCategoriesByRole' => true
    ]
```

* **hidePubblicationDate** - boolean, default = false  
The news created are always visible, hide fields publication_from, publication_to

* **newsRequiredFields** - array, default = ['news_categorie_id', 'titolo', 'status', 'descrizione_breve']  
Mandatory fields in news form: by default news category, title and status are mandatory.  
If in your platform, for example, you don't want title to be a mandatory field, overwrite newsRequiredFields property as below:
```php
'news' => [
Aster's avatar
Aster committed
126
    'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
127
128
129
130
131
132
133
134
    'newsRequiredFields' => ['news_categorie_id', 'status']  
],
```

* **defaultCategory** - integer 
The ID of the default category pre-selected for the new News
```php
'news' => [
Aster's avatar
Aster committed
135
    'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
136
137
138
139
140
141
142
    'defaultCategory' => 3  
],
```
* **autoUpdatePublicationDate** - boolean, default = false  
This set the auto update of the publication date on the save if the news is published
```php
'news' => [
Aster's avatar
Aster committed
143
    'class' => 'arter\amos\news\AmosNews',
Marcello Pivanti's avatar
Marcello Pivanti committed
144
145
146
    'autoUpdatePublicationDate' => true
],
```
Aster's avatar
Aster committed
147
148
149
150
151
152

* **$enableCategoriesForCommunity** - boolean, default = false  
* **$showAllCategoriesForCommunity** - boolean, default = false  
* **$whiteListRolesCategories** - default = ['ADMIN', 'BASIC_USER']