Scroll To Top

Xin hướng dẫn: Hiển thị tin trên trang chủ

Đăng lúc: Thứ ba - 25/10/2016 11:25 |  NukeViet | : Người đưa tin | Đã xem: 1740 |   0

Xin hướng dẫn: Hiển thị tin trên trang chủ

Xin hướng dẫn hiển thị tin theo chuyên mục trên trang chủ như hình

demo: https://mynukeviet.net :D

mynuke
 

Hơi loằng ngoằng nha, chịu khó sẽ thành công :D

Cái này chỉ áp dụng cho kiểu hiển thị là Chủ đề, tin khác bên phải, nên bạn phải vào cấu hình module news để chọn kiểu này trước.

1, Mở themes/ten-theme/css/news.css

Thêm vào cuối file

.related img {
float: left;
margin-right: 10px;
}
.main .news_column .panel-body{
    padding: 0;
    padding-top: 5px
}
.main .news_column .panel-body ul{
    margin-left: 0    
}
.main .news_column .panel-body h2{
    margin: 8px 0 8px 0;    
}
.main .news_column .panel-body ul.related .h4{
    margin: 0;
    font-weight: bold;
    line-height: 20px;
}

2, Mở themes/ten-theme/modules/news/viewcat_main_right.tpl

Tìm

<div class="{WCT}">

Thay bằng

<div class="col-xs-24 col-sm-12 col-md-12">

Tìm

<a title="{CONTENT.title}" href="{CONTENT.link}"><img src="{HOMEIMG}" alt="{HOMEIMGALT}" width="{IMGWIDTH}" class="img-thumbnail pull-left imghome" /></a>

Thay bằng

<a title="{CONTENT.title}" href="{CONTENT.link}"><img src="{HOMEIMG}" alt="{HOMEIMGALT}"class="img-thumbnail imghome" /></a>

Tìm

<li><em class="fa fa-eye">&nbsp;</em> {CONTENT.hitstotal}</li>

Thay bằng

<li><em class="fa fa-eye">&nbsp;</em>{LANG.view}: {CONTENT.hitstotal}</li>

Tìm

<li><em class="fa fa-comment-o">&nbsp;</em> {CONTENT.hitscm}</li>

Thay bằng

<li><em class="fa fa-comment-o">&nbsp;</em>{LANG.total_comment}: {CONTENT.hitscm}

Tìm

<div class="col-md-8">

Thay bằng

<div class="col-xs-24 col-sm-12 col-md-12">

Tìm

<li class="{CLASS}">

Thay bằng

<li class="{CLASS} clearfix m-bottom">
    <img src="{OTHER.imghome}" class="img-thumbnail" width="80" />

Tìm

<a class="show h4" href="{OTHER.link}" title="{OTHER.title}" <!-- BEGIN: tooltip -->data-content="{OTHER.hometext}" data-img="{OTHER.imghome}" data-rel="tooltip" data-placement="{TOOLTIP_POSITION}"<!-- END: tooltip -->>{OTHER.title}</a>

Thêm bên dưới

<div class="text-muted">
    <ul class="list-unstyled list-inline">
        <li><em class="fa fa-eye">&nbsp;</em>{LANG.view}: {OTHER.hitstotal}</li>
        <!-- BEGIN: comment -->
        <li><em class="fa fa-comment-o">&nbsp;</em>{LANG.total_comment}: {OTHER.hitscm}</li>
        <!-- END: comment -->
    </ul>
</div>

3, Hãy kiểm tra, nếu tồn tại themes/ten-theme/modules/news/theme.php thì hãy mở file theme.php này, ngược lại, nếu không tồn tại, hãy mở modules/news/theme.php
(Tuy nhiên, mình khuyến khích copy modules/news/theme.php vào themes/ten-theme/modules/news/theme.php rồi chỉnh sửa ở đây, để không làm ảnh hưởng đến việc nâng cấp module news sau này)

Tìm đến hàm viewsubcat_main, trong hàm này (Lưu ý là trong hàm này thôi nhé)

Tìm

global

Thêm biến $module_upload vào cuối danh sách

global $module_name, $module_file, $site_mods, $global_array_cat, $lang_module, $module_config, $module_info, $module_upload;

Tìm

$xtpl->assign('HOMEIMG', $array_row_i['imghome']);

Thay bằng

$xtpl->assign('HOMEIMG', nv_news_resize_crop_images(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $array_row_i['homeimgfile'], 380, 250, $module_name));

Tìm

$xtpl->parse('main.listcat.related.loop');

Thêm lên trên

if (isset($site_mods['comment']) and isset($module_config[$module_name]['activecomm']) and $module_config[$module_name]['activecomm']) {
     $xtpl->parse('main.listcat.related.loop.comment');
}

Thêm nội dung này vào cuối file

function nv_news_resize_crop_images( $img_path, $width, $height, $module_name = '', $id = 0 )
 {
     $new_img_path = str_replace( NV_ROOTDIR, '', $img_path );
     if( file_exists( $img_path ) )
     {
         $imginfo = nv_is_image( $img_path );
         $basename = basename( $img_path );
         $basename = preg_replace( '/^\W+|\W+$/', '', $basename );
         $basename = preg_replace( '/[ ]+/', '_', $basename );
         $basename = strtolower( preg_replace( '/\W-/', '', $basename ) );
         if( $imginfo['width'] > $width or $imginfo['height'] > $height )
         {
             $basename = preg_replace( '/(.*)(\.[a-zA-Z]+)$/', $module_name . '_' . $id . '_\1_' . $width . '-' . $height . '\2', $basename );
             if( file_exists( NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename ) )
             {
                 $new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
             }
             else
             {
                 $img_path = new NukeViet\Files\Image( $img_path, NV_MAX_WIDTH, NV_MAX_HEIGHT );

                 $thumb_width = $width;
                 $thumb_height = $height;
                 $maxwh = max( $thumb_width, $thumb_height );
                 if( $img_path->fileinfo['width'] > $img_path->fileinfo['height'] )
                 {
                     $width = 0;
                     $height = $maxwh;
                 }
                 else
                 {
                     $width = $maxwh;
                     $height = 0;
                 }

                 $img_path->resizeXY( $width, $height );
                 $img_path->cropFromCenter( $thumb_width, $thumb_height );
                 $img_path->save( NV_ROOTDIR . '/' . NV_TEMP_DIR, $basename );
                 if( file_exists( NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $basename ) )
                 {
                     $new_img_path = NV_BASE_SITEURL . NV_TEMP_DIR . '/' . $basename;
                 }
             }
         }

     }
     return $new_img_path;
 }

Nguồn tin: mynukeviet.net:

 Bài viết thuộc chuyên mục: NukeViet

+ Thủ thuật soạn bài giảng E-learning: https://igiaoduc.blogspot.com
+ Diễn đàn hỗ trợ soạn bài giảng E-Learning: https://www.facebook.com/groups/baigiangelearning

 

Tip:Bài viết, video, hình ảnh, vui lòng gửi về địa chỉ email: Phavaphugmail.com


Tổng số điểm của bài viết là: 0 trong 0 đánh giá

Click để đánh giá bài viết
 Từ khóa: hướng dẫn

  Ý kiến bạn đọc

Ðiều sai lầm duy nhất là phủ nhận những gì trái tim mình thật sự cảm nhận. - The only wrong thing would be to deny what your heart truly feels.

kenhbgyoutube

 

 

 

 

 

 

BÌNH LUẬN MỚI NHẤT - TIN TỨC
BÌNH LUẬN MỚI NHẤT - WINDOWS
MỖI LÚC MỘT NỤ CƯỜI
Thống kê truy cập
  • Đang truy cập189
  • Hôm nay22,589
  • Tháng hiện tại790,430
  • Tổng lượt truy cập44,906,133
Thống kê truy cập
Flag Counter
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây