<!DOCTYPE html>
	<html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
	<head>
<title>Hướng dẫn sử dụng tính năng comment cho các module</title>
<meta name="description" content="Hướng dẫn sử dụng tính năng comment cho các module - Savefile - Tin Tức -...">
<meta name="author" content="Trung tâm đào tạo NukeViet">
<meta name="copyright" content="Trung tâm đào tạo NukeViet [admin@nukeviet.edu.vn]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google-site-verification" content="kgyPa58My857f_Ag72D-SrJlLkaTD9H8UkYaCI0eDcg">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Hướng dẫn sử dụng tính năng comment cho các module">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin Tức - https&#x3A;&#x002F;&#x002F;nukeviet.edu.vn&#x002F;savefile&#x002F;Chia-se-kien-thuc-web&#x002F;Huong-dan-su-dung-tinh-nang-comment-cho-cac-module-10.html">
<meta property="og:site_name" content="Trung tâm đào tạo NukeViet">
<meta property="og:url" content="https://nukeviet.edu.vn/savefile/Chia-se-kien-thuc-web/Huong-dan-su-dung-tinh-nang-comment-cho-cac-module-10.html">
<link rel="shortcut icon" href="https://nukeviet.edu.vn/favicon.ico">
<link rel="canonical" href="https://nukeviet.edu.vn/savefile/Chia-se-kien-thuc-web/Huong-dan-su-dung-tinh-nang-comment-cho-cac-module-10.html">
<link rel="alternate" href="https://nukeviet.edu.vn/rss/" title="Tin Tức" type="application/rss+xml">
<link rel="alternate" href="https://nukeviet.edu.vn/rss/Chia-se-kien-thuc-web/" title="Tin Tức - Chia sẻ kiến thức web" type="application/rss+xml">
<link rel="alternate" href="https://nukeviet.edu.vn/rss/Thong-bao/" title="Tin Tức - Thông báo" type="application/rss+xml">
<link rel="alternate" href="https://nukeviet.edu.vn/rss/Dao-tao-web/" title="Tin Tức - Đào tạo web" type="application/rss+xml">
<link rel="alternate" href="https://nukeviet.edu.vn/rss/Tin-tuc-cong-nghe/" title="Tin Tức - Tin tức công nghệ" type="application/rss+xml">
<link rel="preload" as="style" href="https://nukeviet.edu.vn/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/bootstrap.min.css" type="text/css">
<link rel="preload" as="style" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/style.responsive.css" type="text/css">
<link rel="preload" as="style" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/news.css" type="text/css">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/themes/nukeviet_edu/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/themes/nukeviet_edu/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://nukeviet.edu.vn/themes/nukeviet_edu/js/bootstrap.min.js" type="text/javascript">
<link rel="StyleSheet" href="https://nukeviet.edu.vn/assets/css/font-awesome.min.css">
<link rel="StyleSheet" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/bootstrap.min.css">
<link rel="StyleSheet" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/style.css">
<link rel="StyleSheet" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/style.responsive.css">
<link rel="StyleSheet" href="https://nukeviet.edu.vn/themes/nukeviet_edu/css/news.css">
<style type="text/css">
	body{background: #fff;}
</style>
		<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-T5KSND2');</script>
<!-- End Google Tag Manager -->

	</head>
	<body>
	<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-T5KSND2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">Trung tâm đào tạo NukeViet</h2>
		<p class="pull-right"><a title="Trung tâm đào tạo NukeViet" href="https://nukeviet.edu.vn/">https://nukeviet.edu.vn</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Hướng dẫn sử dụng tính năng comment cho các module</h1>
		<ul class="list-inline">
			<li>Thứ năm - 13/03/2014 03:37</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
			Từ phiên bản NukeViet 4.0, NukeViet bổ sung module Comment làm module hệ thống, có chức năng quản lý bình luận chung cho các module. Module comment giúp việc quản lý các bình luận từ thành viên một cách tập trung, giúp việc quản lý đơn giản hơn.
		</div>
		<div id="bodytext" class="clearfix">
			<p style="line-height: 25px;"><span style="font-size:14px;"><span style="line-height: 1.6;">1) Xóa comment của module cũ đi nếu có</span></span></p><p style="line-height: 25px;">&nbsp;</p><p style="line-height: 25px;"><span style="font-size:14px;"><span style="line-height: 1.6;">2) Thêm đoạn sau vào file <strong>modules\module_name\funcs\detail.php</strong></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 205);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">// comment<br  />define( &#039;NV_COMM_ID&#039;, $news_contents[&#039;id&#039;] ); // Bắt buộc</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 205);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">define( &#039;NV_COMM_ALLOWED&#039;, $news_contents[&#039;allowed_comm&#039;] ); // Không bắt buộc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 205);"><span style="font-size: 14px; font-family: &#039;courier new&#039;, courier, monospace;">define( &#039;NV_COMM_AREA&#039;, 0 ); // Không bắt buộc</span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 205);"><span style="line-height: 1.6; font-size: 14px; font-family: &#039;courier new&#039;, courier, monospace;">require_once NV_ROOTDIR . &#039;/modules/comment/comment.php&#039;;</span></span></p><p style="line-height: 25px;"><span style="font-size:14px;"><em><strong>Trong đó:</strong></em><br  /><em>$news_contents[&#039;id&#039;]</em>: là id của bài viết<br  /><em>$news_contents[&#039;allowed_comm&#039;]</em>: Cho phép ai bình luận (<br  />= 0 &lt;===&gt; Không cho ai bình luận<br  />= 1 &lt;===&gt; Tất cả mọi người<br  />= 2 &lt;===&gt; Chỉ có thành viên site</span></p><p style="line-height: 25px;"><span style="font-size: 14px; line-height: 1.6;">NV_COMM_AREA: Khu vực comment, nếu module chỉ có 1 khu vực duy nhất thì thiết lập&nbsp;</span><span style="font-size: 14px; line-height: 1.6;">define( &#039;NV_COMM</span><span style="font-size: 14px; line-height: 1.6;">_AREA&#039;, 0 );</span></p><p style="line-height: 25px;"><span style="font-size:14px;">Nếu module có nhiều khu vực comment thì cần thiết mập mỗi khu vực 1 NV_COMM_AREA, với giá trị khác nhau lớn hơn 0</span></p><p style="line-height: 25px;">&nbsp;</p><p style="line-height: 25px;"><span style="font-size: 14px; line-height: 1.6;">3) Trong file <strong>modules/module_name/theme.php hoặc themes/theme_name/modules/module_name/theme.php</strong></span></p><p style="line-height: 25px;"><span style="font-size: 14px; line-height: 1.6;">Tìm đến đoạn của function hiển thị giao diện</span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$xtpl-&gt;parse( &#039;main&#039; );</span></span></span></p><p style="line-height: 25px;"><span style="font-size:14px;">Thêm đoạn sau</span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">if( defined( &#039;NV_COMM_URL&#039; ) )</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">{</span></span></span></p><p style="line-height: 25px; margin-left: 80px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$xtpl-&gt;assign( &#039;NV_COMM_URL&#039;, NV_COMM_URL );</span></span></span></p><p style="line-height: 25px; margin-left: 80px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$xtpl-&gt;parse( &#039;main.comment&#039; );</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">}</span></span></span></p><p style="line-height: 25px;"><span style="font-size:14px;">Trong giao diện html thêm đoạn sau</span></p><p style="line-height: 25px; margin-left: 40px;"><img alt="" height="68" src="http://nukeviet.edu.vn/uploads/news/2014_03/capture.jpg" width="544" /></p><p style="line-height: 25px;"><span style="font-size: 14px; line-height: 25px;">4) </span><span style="font-size: 14px; line-height: 22.399999618530273px;">&nbsp;Trong file action tạo CSDL&nbsp;</span><em style="font-size: 14px; line-height: 22.399999618530273px;"><strong>(modules/ten-module/action.php)</strong></em><span style="font-size: 14px; line-height: 22.399999618530273px;">&nbsp;của module cần thêm đoạn code sau để tạo dữ liệu cài đặt cho module</span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">// Comments</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;auto_postcomm&#039;, &#039;1&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;allowed_comm&#039;, &#039;3&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;setcomm&#039;, &#039;2&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;activecomm&#039;, &#039;1&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;emailcomm&#039;, &#039;1&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;adminscomm&#039;, &#039;&#039;)&quot;;</span></span></span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:14px;">$sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . $lang . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;sortcomm&#039;, &#039;0&#039;)&quot;;</span></span></span></p><p style="line-height: 25px;"><span style="line-height: 25px; font-size: 14px;">5)&nbsp;</span><span style="font-size: 14px; line-height: 22.399999618530273px;"> Nếu module đã tồn tại bạn cần tạo file php, ví dụ<strong><em> commen-page</em></strong><em><strong>1.php&nbsp;</strong></em>với nội dung bên dưới, đặt ngang hàng với file index.php</span></p><p style="line-height: 25px; margin-left: 40px;"><span style="color:rgb(0, 0, 255);"><span style="font-family:courier new,courier,monospace;"><span style="font-size:12px;">/**<br  />* @Project NUKEVIET 4.x<br  />* @Author VINADES.,JSC (contact@vinades.vn)<br  />* @Copyright (C) 2014 VINADES.,JSC. All rights reserved<br  />* @License GNU/GPL version 2 or any later version<br  />* @Createdate Sat, 08 Feb 2014 06:33:39 GMT<br  />*/<br  />define(&#039;NV_SYSTEM&#039;, true);<br  />require str_replace(DIRECTORY_SEPARATOR, &#039;/&#039;, dirname(__file__)) . &#039;/mainfile.php&#039;;<br  />require NV_ROOTDIR . &#039;/includes/core/user_functions.php&#039;;<br  />if ( defined( &#039;NV_IS_SPADMIN&#039; ) )<br  />{<br  />&nbsp; &nbsp; // Comments<br  />&nbsp; &nbsp; $module_name = &#039;page&#039;;// Sửa ứng với module<br  />&nbsp; &nbsp; $sql_create_module = array();<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;auto_postcomm&#039;, &#039;1&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;allowed_comm&#039;, &#039;3&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;setcomm&#039;, &#039;2&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;activecomm&#039;, &#039;1&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;emailcomm&#039;, &#039;1&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;adminscomm&#039;, &#039;&#039;)&quot;;<br  />&nbsp; &nbsp; $sql_create_module[] = &quot;INSERT INTO &quot; . NV_CONFIG_GLOBALTABLE . &quot; (lang, module, config_name, config_value) VALUES (&#039;&quot; . NV_LANG_DATA . &quot;&#039;, &#039;&quot; . $module_name . &quot;&#039;, &#039;sortcomm&#039;, &#039;0&#039;)&quot;;<br  />&nbsp; &nbsp; foreach( $sql_create_module as $_sql )<br  />&nbsp; &nbsp; {<br  />&nbsp; &nbsp; &nbsp; &nbsp; $db-&gt;query( $_sql );<br  />&nbsp; &nbsp; }<br  />&nbsp; &nbsp; die( &#039;Thuc hien nang cap xong, hay xoa file nay ngay&#039; );<br  />}<br  />else<br  />{<br  />&nbsp; &nbsp; die( &#039;Can thuc hien voi quyen admin toi cao&#039; );<br  />}</span></span></span><br  />&nbsp;</p><p>Đăng nhập bằng tài khoản quản trị tối cao và nhập đường dẫn: http://yourdomain.com/commen-page1.php</p><p>Sau khi nhận được thông báo &quot;Thực hiện nâng cấp thành công&quot;, tiến hành xóa file này khỏi host.</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://nukeviet.edu.vn/savefile/Chia-se-kien-thuc-web/Huong-dan-su-dung-tinh-nang-comment-cho-cac-module-10.html" title="Hướng dẫn sử dụng tính năng comment cho các module">https://nukeviet.edu.vn/savefile/Chia-se-kien-thuc-web/Huong-dan-su-dung-tinh-nang-comment-cho-cac-module-10.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; Trung tâm đào tạo NukeViet
		</div>
		<div id="contact">
			<a href="mailto:admin@nukeviet.edu.vn">admin@nukeviet.edu.vn</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://nukeviet.edu.vn/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<script src="https://nukeviet.edu.vn/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv4c_s5qU1",nv_check_pass_mstime=21538000,nv_area_admin=0,nv_safemode=0,theme_responsive=1,nv_recaptcha_ver=2,nv_recaptcha_sitekey="6Ler2ssZAAAAAGDHZD32W4NSMuzz3yaQLqYSu9UK",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://nukeviet.edu.vn/assets/js/language/vi.js"></script>
<script src="https://nukeviet.edu.vn/assets/js/DOMPurify/purify3.js"></script>
<script src="https://nukeviet.edu.vn/assets/js/global.js"></script>
<script src="https://nukeviet.edu.vn/assets/js/site.js"></script>
<script src="https://nukeviet.edu.vn/themes/nukeviet_edu/js/news.js"></script>
<script src="https://nukeviet.edu.vn/themes/nukeviet_edu/js/main.js"></script>
<script src="https://nukeviet.edu.vn/themes/nukeviet_edu/js/bootstrap.min.js"></script>
</body>
</html>