Mình muốn sửa block tin xem nhiều giống như ảnh (tin đầu có hình và các tin khác không hình), ai biết hướng dẫn mình với, cám ơn!
Thảo luận trong 'Modules tin tức' đăng bởi duongnguyen, 24/08/2016 15:49.
Mình muốn sửa block tin xem nhiều giống như ảnh (tin đầu có hình và các tin khác không hình), ai biết hướng dẫn mình với, cám ơn!
------
Chỉnh cái block nào thì ít nhất bác cũng đưa nó lên đây. Bác đưa 2 bàn tay trắng thì nói người ta chỉnh cái gì? Bác đưa hình ảnh lên thì phải nói là xin block chứ.
Kinh nghiệm của mình, nếu bác xin block đại loại vậy thì AE có mới cho, còn chỉnh sửa thì...!
Code của file php như sau
<?php /** * @Project NUKEVIET 4.x * @Author VINADES.,JSC (contact@vinades.vn) * @Copyright (C) 2014 VINADES.,JSC. * All rights reserved * @License GNU/GPL version 2 or any later version * @Createdate 3/9/2010 23:25 */ if (!defined('NV_MAINFILE')) { die('Stop!!!'); } if (!nv_function_exists('nv_news_block_tophits')) { function nv_block_config_tophits_blocks($module, $data_block, $lang_block) { global $nv_Cache, $site_mods; $html = ''; $html .= '<tr>'; $html .= ' <td>' . $lang_block['number_day'] . '</td>'; $html .= ' <td><input type="text" name="config_number_day" class="form-control w100" size="5" value="' . $data_block['number_day'] . '"/></td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= ' <td>' . $lang_block['numrow'] . '</td>'; $html .= ' <td><input type="text" name="config_numrow" class="form-control w100" size="5" value="' . $data_block['numrow'] . '"/></td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td>' . $lang_block['showtooltip'] . '</td>'; $html .= '<td>'; $html .= '<input type="checkbox" value="1" name="config_showtooltip" ' . ($data_block['showtooltip'] == 1 ? 'checked="checked"' : '') . ' /><br /><br />'; $tooltip_position = array( 'top' => $lang_block['tooltip_position_top'], 'bottom' => $lang_block['tooltip_position_bottom'], 'left' => $lang_block['tooltip_position_left'], 'right' => $lang_block['tooltip_position_right'] ); $html .= '<span class="text-middle pull-left">' . $lang_block['tooltip_position'] . ' </span><select name="config_tooltip_position" class="form-control w100 pull-left">'; foreach ($tooltip_position as $key => $value) { $html .= '<option value="' . $key . '" ' . ($data_block['tooltip_position'] == $key ? 'selected="selected"' : '') . '>' . $value . '</option>'; } $html .= '</select>'; $html .= ' <span class="text-middle pull-left">' . $lang_block['tooltip_length'] . ' </span><input type="text" class="form-control w100 pull-left" name="config_tooltip_length" size="5" value="' . $data_block['tooltip_length'] . '"/>'; $html .= '</td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td>' . $lang_block['nocatid'] . '</td>'; $sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'] . '_cat ORDER BY sort ASC'; $list = $nv_Cache->db($sql, '', $module); $html .= '<td>'; $html .= '<div style="height: 200px; overflow: auto">'; if (!is_array($data_block['nocatid'])) { $data_block['nocatid'] = explode(',', $data_block['nocatid']); } foreach ($list as $l) { $xtitle_i = ''; if ($l['lev'] > 0) { for ($i = 1; $i <= $l['lev']; ++$i) { $xtitle_i .= ' '; } } $html .= $xtitle_i . '<label><input type="checkbox" name="config_nocatid[]" value="' . $l['catid'] . '" ' . ((in_array($l['catid'], $data_block['nocatid'])) ? ' checked="checked"' : '') . '</input>' . $l['title'] . '</label><br />'; } $html .= '</div>'; $html .= '</td>'; $html .= '</tr>'; return $html; } function nv_block_config_tophits_blocks_submit($module, $lang_block) { global $nv_Request; $return = array(); $return['error'] = array(); $return['config'] = array(); $return['config']['number_day'] = $nv_Request->get_int('config_number_day', 'post', 0); $return['config']['numrow'] = $nv_Request->get_int('config_numrow', 'post', 0); $return['config']['showtooltip'] = $nv_Request->get_int('config_showtooltip', 'post', 0); $return['config']['tooltip_position'] = $nv_Request->get_string('config_tooltip_position', 'post', 0); $return['config']['tooltip_length'] = $nv_Request->get_string('config_tooltip_length', 'post', 0); $return['config']['nocatid'] = $nv_Request->get_typed_array('config_nocatid', 'post', 'int', array()); return $return; } function nv_news_block_tophits($block_config, $mod_data) { global $module_array_cat, $site_mods, $module_info, $db_slave, $module_config, $global_config; $module = $block_config['module']; $mod_file = $site_mods[$module]['module_file']; $blockwidth = $module_config[$module]['blockwidth']; $show_no_image = $module_config[$module]['show_no_image']; $publtime = NV_CURRENTTIME - $block_config['number_day'] * 86400; $array_block_news = array(); $db_slave->sqlreset() ->select('id, catid, publtime, exptime, title, alias, homeimgthumb, homeimgfile, hometext') ->from(NV_PREFIXLANG . '_' . $mod_data . '_rows') ->order('hitstotal DESC') ->limit($block_config['numrow']); if (empty($block_config['nocatid'])) { $db_slave->where('status= 1 AND publtime > ' . $publtime); } else { $db_slave->where('status= 1 AND publtime > ' . $publtime . ' AND catid NOT IN (' . implode(',', $block_config['nocatid']) . ')'); } $result = $db_slave->query($db_slave->sql()); while (list ($id, $catid, $publtime, $exptime, $title, $alias, $homeimgthumb, $homeimgfile, $hometext) = $result->fetch(3)) { if ($homeimgthumb == 1) { // image thumb $imgurl = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { // image file $imgurl = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { // image url $imgurl = $homeimgfile; } elseif (!empty($show_no_image)) { // no image $imgurl = NV_BASE_SITEURL . $show_no_image; } else { $imgurl = ''; } $link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $module_array_cat[$catid]['alias'] . '/' . $alias . '-' . $id . $global_config['rewrite_exturl']; $array_block_news[] = array( 'id' => $id, 'title' => $title, 'link' => $link, 'imgurl' => $imgurl, 'width' => $blockwidth, 'hometext' => $hometext ); } if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $mod_file . '/block_tophits.tpl')) { $block_theme = $global_config['module_theme']; } else { $block_theme = 'default'; } $xtpl = new XTemplate('block_tophits.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/' . $mod_file); $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL); $xtpl->assign('TEMPLATE', $block_theme); foreach ($array_block_news as $array_news) { $array_news['hometext'] = nv_clean60($array_news['hometext'], $block_config['tooltip_length'], true); $xtpl->assign('blocknews', $array_news); if (!empty($array_news['imgurl'])) { $xtpl->parse('main.newloop.imgblock'); } if (!$block_config['showtooltip']) { $xtpl->assign('TITLE', 'title="' . $array_news['title'] . '"'); } $xtpl->parse('main.newloop'); } if ($block_config['showtooltip']) { $xtpl->assign('TOOLTIP_POSITION', $block_config['tooltip_position']); $xtpl->parse('main.tooltip'); } $xtpl->parse('main'); return $xtpl->text('main'); } } if (defined('NV_SYSTEM')) { global $nv_Cache, $site_mods, $module_name, $global_array_cat, $module_array_cat; $module = $block_config['module']; if (isset($site_mods[$module])) { $mod_data = $site_mods[$module]['module_data']; if ($module == $module_name) { $module_array_cat = $global_array_cat; unset($module_array_cat[0]); } else { $module_array_cat = array(); $sql = 'SELECT catid, parentid, title, alias, viewcat, subcatid, numlinks, description, inhome, keywords, groups_view FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_cat ORDER BY sort ASC'; $list = $nv_Cache->db($sql, 'catid', $module); if(!empty($list)) { foreach ($list as $l) { $module_array_cat[$l['catid']] = $l; $module_array_cat[$l['catid']]['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $l['alias']; } } } $content = nv_news_block_tophits($block_config, $mod_data); } }
Mình muốn phân ra làm 2 phần: phần top để lấy ảnh và title; phần newloop chỉ để lấy các title thôi, bác phavaphu sửa giúp file php này với. Còn file tpl hay css mình tự mò. Thanks
Thay thế toàn bộ PHP bằng nội dung bên dưới:
<?php /** * @Project NUKEVIET 4.x * @Author VINADES.,JSC (contact@vinades.vn) * @Copyright (C) 2014 VINADES.,JSC. * All rights reserved * @License GNU/GPL version 2 or any later version * @Createdate 3/9/2010 23:25 */ if (!defined('NV_MAINFILE')) { die('Stop!!!'); } if (!nv_function_exists('nv_news_block_tophits')) { function nv_block_config_tophits_blocks($module, $data_block, $lang_block) { global $nv_Cache, $site_mods; $html = ''; $html .= '<tr>'; $html .= ' <td>' . $lang_block['number_day'] . '</td>'; $html .= ' <td><input type="text" name="config_number_day" class="form-control w100" size="5" value="' . $data_block['number_day'] . '"/></td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= ' <td>' . $lang_block['numrow'] . '</td>'; $html .= ' <td><input type="text" name="config_numrow" class="form-control w100" size="5" value="' . $data_block['numrow'] . '"/></td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td>' . $lang_block['showtooltip'] . '</td>'; $html .= '<td>'; $html .= '<input type="checkbox" value="1" name="config_showtooltip" ' . ($data_block['showtooltip'] == 1 ? 'checked="checked"' : '') . ' /><br /><br />'; $tooltip_position = array( 'top' => $lang_block['tooltip_position_top'], 'bottom' => $lang_block['tooltip_position_bottom'], 'left' => $lang_block['tooltip_position_left'], 'right' => $lang_block['tooltip_position_right'] ); $html .= '<span class="text-middle pull-left">' . $lang_block['tooltip_position'] . ' </span><select name="config_tooltip_position" class="form-control w100 pull-left">'; foreach ($tooltip_position as $key => $value) { $html .= '<option value="' . $key . '" ' . ($data_block['tooltip_position'] == $key ? 'selected="selected"' : '') . '>' . $value . '</option>'; } $html .= '</select>'; $html .= ' <span class="text-middle pull-left">' . $lang_block['tooltip_length'] . ' </span><input type="text" class="form-control w100 pull-left" name="config_tooltip_length" size="5" value="' . $data_block['tooltip_length'] . '"/>'; $html .= '</td>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td>' . $lang_block['nocatid'] . '</td>'; $sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'] . '_cat ORDER BY sort ASC'; $list = $nv_Cache->db($sql, '', $module); $html .= '<td>'; $html .= '<div style="height: 200px; overflow: auto">'; if (!is_array($data_block['nocatid'])) { $data_block['nocatid'] = explode(',', $data_block['nocatid']); } foreach ($list as $l) { $xtitle_i = ''; if ($l['lev'] > 0) { for ($i = 1; $i <= $l['lev']; ++$i) { $xtitle_i .= ' '; } } $html .= $xtitle_i . '<label><input type="checkbox" name="config_nocatid[]" value="' . $l['catid'] . '" ' . ((in_array($l['catid'], $data_block['nocatid'])) ? ' checked="checked"' : '') . '</input>' . $l['title'] . '</label><br />'; } $html .= '</div>'; $html .= '</td>'; $html .= '</tr>'; return $html; } function nv_block_config_tophits_blocks_submit($module, $lang_block) { global $nv_Request; $return = array(); $return['error'] = array(); $return['config'] = array(); $return['config']['number_day'] = $nv_Request->get_int('config_number_day', 'post', 0); $return['config']['numrow'] = $nv_Request->get_int('config_numrow', 'post', 0); $return['config']['showtooltip'] = $nv_Request->get_int('config_showtooltip', 'post', 0); $return['config']['tooltip_position'] = $nv_Request->get_string('config_tooltip_position', 'post', 0); $return['config']['tooltip_length'] = $nv_Request->get_string('config_tooltip_length', 'post', 0); $return['config']['nocatid'] = $nv_Request->get_typed_array('config_nocatid', 'post', 'int', array()); return $return; } function nv_news_block_tophits($block_config, $mod_data) { global $module_array_cat, $site_mods, $module_info, $db_slave, $module_config, $global_config; $module = $block_config['module']; $mod_file = $site_mods[$module]['module_file']; $blockwidth = $module_config[$module]['blockwidth']; $show_no_image = $module_config[$module]['show_no_image']; $publtime = NV_CURRENTTIME - $block_config['number_day'] * 86400; $array_block_news = array(); $db_slave->sqlreset() ->select('id, catid, publtime, exptime, title, alias, homeimgthumb, homeimgfile, hometext') ->from(NV_PREFIXLANG . '_' . $mod_data . '_rows') ->order('hitstotal DESC') ->limit($block_config['numrow']); if (empty($block_config['nocatid'])) { $db_slave->where('status= 1 AND publtime > ' . $publtime); } else { $db_slave->where('status= 1 AND publtime > ' . $publtime . ' AND catid NOT IN (' . implode(',', $block_config['nocatid']) . ')'); } $result = $db_slave->query($db_slave->sql()); while (list ($id, $catid, $publtime, $exptime, $title, $alias, $homeimgthumb, $homeimgfile, $hometext) = $result->fetch(3)) { if ($homeimgthumb == 1) { // image thumb $imgurl = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { // image file $imgurl = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { // image url $imgurl = $homeimgfile; } elseif (!empty($show_no_image)) { // no image $imgurl = NV_BASE_SITEURL . $show_no_image; } else { $imgurl = ''; } $link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $module_array_cat[$catid]['alias'] . '/' . $alias . '-' . $id . $global_config['rewrite_exturl']; $array_block_news[] = array( 'id' => $id, 'title' => $title, 'link' => $link, 'imgurl' => $imgurl, 'width' => $blockwidth, 'hometext' => $hometext ); } if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $mod_file . '/block_tophits.tpl')) { $block_theme = $global_config['module_theme']; } else { $block_theme = 'default'; } $xtpl = new XTemplate('block_tophits.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/' . $mod_file); $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL); $xtpl->assign('TEMPLATE', $block_theme); $_me = 0; foreach ($array_block_news as $array_news) { $_me++; $array_news['hometext'] = nv_clean60($array_news['hometext'], $block_config['tooltip_length'], true); $xtpl->assign('blocknews', $array_news); if (!empty($array_news['imgurl']) AND $_me == 1) { $xtpl->parse('main.newloop.imgblock'); } if (!$block_config['showtooltip']) { $xtpl->assign('TITLE', 'title="' . $array_news['title'] . '"'); } $xtpl->parse('main.newloop'); } if ($block_config['showtooltip']) { $xtpl->assign('TOOLTIP_POSITION', $block_config['tooltip_position']); $xtpl->parse('main.tooltip'); } $xtpl->parse('main'); return $xtpl->text('main'); } } if (defined('NV_SYSTEM')) { global $nv_Cache, $site_mods, $module_name, $global_array_cat, $module_array_cat; $module = $block_config['module']; if (isset($site_mods[$module])) { $mod_data = $site_mods[$module]['module_data']; if ($module == $module_name) { $module_array_cat = $global_array_cat; unset($module_array_cat[0]); } else { $module_array_cat = array(); $sql = 'SELECT catid, parentid, title, alias, viewcat, subcatid, numlinks, description, inhome, keywords, groups_view FROM ' . NV_PREFIXLANG . '_' . $mod_data . '_cat ORDER BY sort ASC'; $list = $nv_Cache->db($sql, 'catid', $module); if(!empty($list)) { foreach ($list as $l) { $module_array_cat[$l['catid']] = $l; $module_array_cat[$l['catid']]['link'] = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module . '&' . NV_OP_VARIABLE . '=' . $l['alias']; } } } $content = nv_news_block_tophits($block_config, $mod_data); } }
Kết quả: