Подскажите пожалуйста, как сделать кнопку опубликовать, что бы каждый раз не лезть в админку.
Версия 1.10.3 в настройках принимать комментарии от посетителей с модерацией
InstantCMS 1.X
Пробую методом тыка
В com_comments_list.tpl
<a href="javascript:" onclick="publishComment('{$comment.id}', '{csrf_token}')" class="ajaxlink">{$LANG.PUBLISH}</a>
В comments.js
function publishComment(comment_id, csrf_token){
$.ajax({
type:"POST",
url:"/components/comments/script.php",
data:"comment_id" + comment_id,});
}
В script.php
<?php
function publishComment($comment_id){
$inDB = cmsDatabase::getInstance();
$inDB->query("UPDATE cms_comments SET published = 1 WHERE id = $comment_id") ;
}
?>
Подскажите, в чем ошибка?
В com_comments_list.tpl
<a href="javascript:" onclick="publishComment('{$comment.id}', '{csrf_token}')" class="ajaxlink">{$LANG.PUBLISH}</a>
В comments.js
function publishComment(comment_id, csrf_token){
$.ajax({
type:"POST",
url:"/components/comments/script.php",
data:"comment_id" + comment_id,});
}
В script.php
<?php
function publishComment($comment_id){
$inDB = cmsDatabase::getInstance();
$inDB->query("UPDATE cms_comments SET published = 1 WHERE id = $comment_id") ;
}
?>
Подскажите, в чем ошибка?
#3
26 января 2017 в 17:21
@chameleon9,
А так не проще будет?
В comments.js
script.php
А так не проще будет?
В comments.js
function publishComment(comment_id, csrf_token){ $.post('/components/comments/script.php', {comment_id: comment_id}); }
<?php include(PATH.'/core/ajax/ajax_core.php'); $inDB = cmsDatabase::getInstance(); $comment_id = $_POST['comment_id']; $inDB->query("UPDATE cms_comments SET published = 1 WHERE id = $comment_id") ; ?>
Сегодня в 07:01
#4
26 января 2017 в 17:25
Огромное спасибо, всё работает