Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use in yii2-advanced #10

Closed
hustcrab opened this issue May 25, 2016 · 6 comments
Closed

how to use in yii2-advanced #10

hustcrab opened this issue May 25, 2016 · 6 comments

Comments

@hustcrab
Copy link

I don't know <?php echo \yii2mod\comments\widgets\Comment::widget([ 'model' => $model, 'relatedTo' => 'User ' . \Yii::$app->user->identity->username . ' commented on the page ' . \yii\helpers\Url::current() // for example ]); ?> about what is the '$model'. Is't a model =new user?

@ihorchepurnyi
Copy link
Contributor

Hi, for example:

$model = PostModel::findOne(['title' => 'some post title']);
$model = UserModel::find()->where(['email' => 'some email'])->one();

@hustcrab
Copy link
Author

Can I use it in yii2 -advanced/frontend/views straightly? Thank you.

@hustcrab
Copy link
Author

I saw the second closed issues. May I have to use 'en-US' in my application if I want to use this.

@ihorchepurnyi
Copy link
Contributor

Can I use it in yii2 -advanced/frontend/views straightly? Thank you.

yes, of course. Code for example:

// In your controller

$post = PostModel::findOne(['title' => 'your post title']);

return $this->render('your view', [
  'post' => $post
]);

// In your view file

<?php echo \yii2mod\comments\widgets\Comment::widget([
    'model' => $post,
    'relatedTo' => 'User ' . \Yii::$app->user->identity->username . ' commented on the page ' . \yii\helpers\Url::current() // for example
]); ?>

May I have to use 'en-US' in my application if I want to use this.

Yes, of course. Yii2 by default used the 'en-US' language.

@hustcrab
Copy link
Author

What's the 'PostModel' ?

@ihorchepurnyi
Copy link
Contributor

What's the 'PostModel' ?

This model just for example, you need to use your own models in your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants