Answer the question
In order to leave comments, you need to log in
How to set up rendering when logging in via dektrium/yii2-user social networks?
There is a form for comments, it is located under the blog article:
As you can see, you can enter the name and email yourself, or log in through social networks and leave a comment.
But the problem is that after logging in via social networks, the page reloads, and the user finds himself in the header of the article, and in order to leave a comment, he needs to go down the page again...
Is it possible to somehow configure the login so that only the block with comments is updated? like with ajax...
In web.php I have it configured like this:
'modules' => [
'user' => [
'class' => 'dektrium\user\Module',
'security' => [
'class' => \dektrium\user\controllers\SecurityController::className(),
'on ' . \dektrium\user\controllers\SecurityController::EVENT_BEFORE_AUTHENTICATE => function ($e) {
/**
* В контроллере ArticleController сохранил путь - \yii\helpers\Url::remember('', 'actions-article');
* И здесь получил его:
**/
$previous = yii\helpers\Url::previous('actions-article');
// Если путь сохранен, то он переходит на эту страницу, если нет, то на главную
if($previous) {
Yii::$app->user->setReturnUrl(Yii::$app->request->hostInfo.$previous);
} else {
Yii::$app->user->setReturnUrl(Url::home());
}
},
],
],
],
]
Answer the question
In order to leave comments, you need to log in
Is it possible to somehow configure the input so that only the block with comments is updated? like with ajax...
public function actionLogin()
{
//your code for login
return $this->redirect(['profile', 'id' => $id, '#' => 'comment']);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question