var updateComments() = function () {
$.ajax({
url: `${baseUrl}/comments`,
type: 'get',
contentType: 'json',
success: function (data) {
console.log(data);
data.forEach(function (item) {
comments.append('<div class="message" id="' + item.comment_id + '"><div>' + item.text + '</div><div data-likeid="' + item.comment_id + '">likes:' + item.likes + '</div><a href="#" class="likebutton" data-idcomment="' + item.comment_id + '">Like</a></div>')
});
});
}
addButton.click(function () {
const product = productInput.val();
const price = priceInput.val();
$.ajax({
url: `${baseUrl}/shop?user_id=${userId}&product=${product}&price=${price}`,
type: 'post',
contentType: 'json',
success: function (data) {
console.log(data);
updateComments();
}
});
});
public function actionView($id)
{
$post = $this->findModel($id);
Yii::$app->response->headers->set('Last-Modified',strtotime($post->updated));
Yii::$app->response->headers->set('ETag',serialize([$post->updated, $post->views, $post->comments, Yii::$app->user->isGuest ? 0 : 1]););
return $this->render('view', [
'model' => $post,
]);
}
public function render($file, $params, $return = false) {
$template = $this->dir_tmpl.$file.'.tpl';
die($template);
public function render($file, $params, $return = false) {
$template = 'D:/sites/mysite.local/mvc/tmpl/'.$file.'.tpl';
$code_js = preg_replace('~ *([+{}()=:;\*]) *~s', '$1', $code_js);