New version 0.9 has been released! Jun 16, 2015
×

Guestbook module

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] => 1623998243
            [date] => "Jun 18, 2021, 9:37:23 AM"
        )

)

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.