Description
Guestbook module helps you to create live editable guestbook and form on frontend.
Include
use yii\easyii\modules\guestbook\api\Guestbook;
Public functions
string Guestbook::form()
|
Returns fully worked standalone html form. |
array Guestbook::all( $options = [] )
|
$options |
array |
- pageSize (int) - news count on single page
- where (array) - additional select condition
|
examples
Guestbook::all();
|
Returns array of guestbook objects |
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => "User name"
[title] => "Post title"
[text] => "User text"
[answer] => "Admin answer"
[time] => 1652717895
[date] => "May 16, 2022, 7:18:15 PM"
)
)
|
array Guestbook::create( $attributes )
|
If you using your own form, this function will be useful for manual saving guestbook posts.
|
$attributes |
array |
- name (string) *
- text (string) *
- title (string)
- g-recaptcha-response (string) - needed, if "enableCaptcha" module setting is true.
* - required attributes
|
examples
Guestbook::create([ 'name' => 'Tester', 'title' => 'Hello there!', 'text' => 'My big feedback to you' ]);
|
Array
(
[result] => success
)
|
IF new post successfully saved.
|
Array
(
[result] => error
[error] => Array
(
[0] => array
[1] => of
[2] => errors
)
)
|
IF new post saving failed.
|
mixed Guestbook::last( $limit = 1 )
|
$limit |
integer |
Count of last guestbook posts |
examples
Guestbook::last(3);
|
guestbook object
|
IF limit == 1 |
array[3] of guestbook objects
|
IF limit > 1 |
string Guestbook::pages()
|
returns pagination html generated by yii\widgets\LinkPager widget. |
object Guestbook::pagination()
|
returns yii\data\Pagination object. |