programming4:note
Đây là một phiên bản cũ của tài liệu!
Các lưu ý khi lập trình NukeViet 4.x
- Để thêm nội dung vào phần head và footer của site, ta lưu nội dung đó vào hai biến $my_head và $my_footer.
Ví dụ:
$my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/jquery/jquery.imgpreload.min.js\"></script>\n"; $my_footer .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "themes/" . $module_info['template'] . "/js/contentslider.js\"></script>\n";
Ngoài ra có thể chèn trực tiếp vào các file tpl, khi xuất ra trình duyệt hệ thống tự động đưa js và css về vị trí thích hợp.
- Để gọi ra editor, thực hiện thao tác:
if (defined('NV_EDITOR')) { require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php'; } $row['bodytext'] = htmlspecialchars(nv_editor_br2nl($row['bodytext'])); if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) { $row['bodytext'] = nv_aleditor('bodytext', '100%', '300px', $row['bodytext']); } else { $row['bodytext'] = '<textarea style="width:100%;height:300px" name="bodytext">' . $row['bodytext'] . '</textarea>'; }
- Để mở cửa sổ upload file ta thực hiện:
$("#selectimages").click( function() { nv_open_browse_file( "{NV_BASE_ADMINURL}index.php?{NV_NAME_VARIABLE}=upload&popup=1&area=images&path={IMG_DIR}&type=image", "NVImg", "850", "500", "resizable=no,scrollbars=no,toolbar=no,location=no,status=no" ); return false; });
- Để mở cửa sổ tìm kiếm ID một thành viên ta thực hiện:
$("#selecteduid").click( function() { nv_open_browse_file( "{NV_BASE_ADMINURL}index.php?" + nv_name_variable + "=users&" + nv_fc_variable + "=getuserid&area=userid", "NVImg", "850", "600", "resizable=no,scrollbars=no,toolbar=no,location=no,status=no" ); return false; });
- NukeViet hỗ trợ các tiến trình tự động, tuy nhiên các tiến trình tự động sẽ không chạy nếu không tồn tại giá trị $_GET['second'] hoặc $_GET['second'] != 'crontjobs', vì vậy trong file theme.php của mỗi theme nhất thiết phải có dòng
$xtpl->assign( 'THEME_IMG_CRONJOBS', NV_BASE_SITEURL . "index.php?second=cronjobs&p=" . nv_genpass() );
Trong phần cuối của website cần có dòng
<img alt="" title="" src="{THEME_IMG_CRONJOBS}" width="1" height="1" />
(Thông thường phần cuối thường do file footer.tpl quyết định).
- Đối với các phiên bản NukeViet trước revision 734, các theme không phải của hệ thống khi nâng cấp lên phiên bản cao hơn cần chú ý:
- Mở file themes/ten_theme_admin/theme.php, tìm đến dòng gần cuối cùng:
$xtpl->out( 'main' );
Thay bằng:
return $xtpl->text( 'main' );
- Mở file themes/ten_theme/theme.php, tìm đến dòng gần cuối cùng:
echo $sitecontent; Thay bằng: <code php> echo $sitecontent;
- Gọi thêm biến global $client_info cho function nv_site_theme trong file theme.php.
- Trong file theme.php thay dòng:
$xtpl->assign( 'THEME_SEARCH_SUBMIT_ONCLICK', "nv_search_submit('topmenu_search_query', 'topmenu_search_submit', " . NV_MIN_SEARCH_LENGTH . ", " . NV_MAX_SEARCH_LENGTH . ");" );
Bằng dòng:
$xtpl->assign( 'THEME_SEARCH_SUBMIT_ONCLICK', "nv_search_submit('topmenu_search_query', 'topmenu_search_checkss', 'topmenu_search_submit', " . NV_MIN_SEARCH_LENGTH . ", " . NV_MAX_SEARCH_LENGTH . ");" ); $xtpl->assign( 'CHECKSS', md5( $client_info['session_id'] . $global_config['sitekey'] ) );
- Trong /themes/default/layout/header.tpl thay dòng (nếu có):
<form action="" method="get" class="search fr" onsubmit="return {THEME_SEARCH_SUBMIT_ONCLICK}">
Bằng dòng:
<form action="{NV_BASE_SITEURL}" method="get" class="search fr" onsubmit="return {THEME_SEARCH_SUBMIT_ONCLICK}"> <input type="hidden" id="topmenu_search_checkss" value="{CHECKSS}" />
programming4/note.1466122873.txt.gz · Sửa đổi lần cuối: 2016/06/17 07:21 bởi hoaquynhtim99