Theo yêu cầu: http://diendan.joomlaviet.vn/thread...new-hoac-hot-vao-tieu-de-bai-viet.58/#post-88 Mình hướng dẫn trên mod_latestnews để hiển thị tin tức, các Mod khác tuỳ biến cũng làm tương tự như vậy thôi nhá Mình làm Topic Hướng dẫn cho ai cần mà chưa làm đc, làm luôn nhé Chi tiết cho các bạn hiểu có thể tuỳ biến hiển thị trên nhiều Mod khác nữa: Mở file helper.php trong mod_latestnews ra = notepad ++ hoặc editplus gì đó Nhấn Ctrl + F (Tìm kiếm) Gõ "title" nhấn Enter Giờ thấy đoạn: ( $row->title ); rồi nhé Thêm đoạn: Mã: ."<img src='/images/new.gif'/>" Ngay sau ( $row->title ) và trước dấu ; Code sẽ thành Mã: ( $row->title )."<img src='/images/new.gif'/>"; Nếu muốn nhanh hơn thì thế này Mở file helper.php trong mod_latestnews thay toàn bộ = code này: Mã: <?php /** * @version $Id: helper.php 14401 2010-01-26 14:10:00Z louis $ * @package Joomla * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined('_JEXEC') or die('Restricted access'); require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); class modLatestNewsHelper { function getList(&$params) { global $mainframe; $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $userId = (int) $user->get('id'); $count = (int) $params->get('count', 5); $catid = trim( $params->get('catid') ); $secid = trim( $params->get('secid') ); $show_front = $params->get('show_front', 1); $aid = $user->get('aid', 0); $contentConfig = &JComponentHelper::getParams( 'com_content' ); $access = !$contentConfig->get('show_noauth'); $nullDate = $db->getNullDate(); $date =& JFactory::getDate(); $now = $date->toMySQL(); $where = 'a.state = 1' . ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' . ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )' ; // User Filter switch ($params->get( 'user_id' )) { case 'by_me': $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')'; break; case 'not_me': $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')'; break; } // Ordering switch ($params->get( 'ordering' )) { case 'm_dsc': $ordering = 'a.modified DESC, a.created DESC'; break; case 'c_dsc': default: $ordering = 'a.created DESC'; break; } if ($catid) { $ids = explode( ',', $catid ); JArrayHelper::toInteger( $ids ); $catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')'; } if ($secid) { $ids = explode( ',', $secid ); JArrayHelper::toInteger( $ids ); $secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')'; } // Content Items only $query = 'SELECT a.*, ' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'. ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'. ' FROM #__content AS a' . ($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') . ' INNER JOIN #__categories AS cc ON cc.id = a.catid' . ' INNER JOIN #__sections AS s ON s.id = a.sectionid' . ' WHERE '. $where .' AND s.id > 0' . ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : ''). ($catid ? $catCondition : ''). ($secid ? $secCondition : ''). ($show_front == '0' ? ' AND f.content_id IS NULL ' : ''). ' AND s.published = 1' . ' AND cc.published = 1' . ' ORDER BY '. $ordering; $db->setQuery($query, 0, $count); $rows = $db->loadObjectList(); $i = 0; $lists = array(); foreach ( $rows as $row ) { if($row->access <= $aid) { $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)); } else { $lists[$i]->link = JRoute::_('index.php?option=com_user&view=login'); } $lists[$i]->text = htmlspecialchars( $row->title )."<img src='/images/new.gif'/>"; $i++; } return $lists; } } Nhanh nữa thì tải file đính kèm về chép đè lên helper.php trong mod_latestnews Nhớ Up file new.gif lên thư mục images nhé Demo: Tới đây thưởng thức thành quả nhé
Hi bạn, mình đã làm theo hướng dẫn nhưng sao hình nó không show được mà chỉ hiện như hình này thôi, mặc dù mình Refresh trang web nhiều lần, nhờ bạn giúp dùm cảm ơn nhiều!
Vẫn up ảnh vào đúng như thế nhưng khi bật chế độ tạo liên kết thân thiện là bị lỗi như thế. Không hiểu sao nữa, khi để mặc định thì bt
( $row->title )."<img src='/images/new.gif'/>"; Hoặc ( $row->title )."<img src='http://domaincuaban.com/images/new.gif'/>"; Sửa link dẫn hình ảnh thành link đầy đủ giống như trên xem có hiện ko
Đường link hoàn hảo như sau: thay dấu / được đánh dấu màu đỏ dưới đây: ( $row->title ) . "<img src='/images/new.gif'/>"; bằng mã " . JURI::base() . " như được đánh dấu màu đỏ dưới đây: ( $row->title ) . "<img src='" . JURI::base() . "images/new.gif'/>"; nó sẽ tự động lấy đường dẫn domain của bạn, vd theo dạng http://bacninhpro.net/ (có / cuối cùng).
Xin cho hỏi..Em chỉ muốn cho tin hót vào bài mà mình muốn co new thôi..thì làm thế nào ạ..Chứ ko phải hót new hết như kia rất bất tiện ạ
Cái này thì mình làm theo hướng dẫn thì ok rồi . Nhưng trường hợp thế này thì ko hay: vi dụ: trang chủ mình có 2 module last new mình chỉ muốn 1 module hiện có chử new nhấp nháy thôi. nếu làm theo cách trên thì 2 module này đều có chử new.
Thêm tiền tố cho modul.modul thường có dạng. <div class="latesnew"><li>...</li>. bạn thêm trong quản lý module --->phần tiền tố modul: _moinhat khi đó modul đó sẽ có dạng <div class="latesnew_moinhat"><li>...</li>. bạn vào file template.css thêm lớp css .latesnew_moinhat {display:block} .latesnew_moinhat li { display:block; background:url(../images/hotnew.gif)no-reapeat right 50%; padding-right: 20px; } Bạn tùy chỉnh code css sao cho phù hợp với website của bạn. Chúc bạn thành công
Cái này phải fix lại chức năng đang tin trong joomla, thêm tùy chọn là có hot hay không? có mình nhu cầu liên hệ mình code!
cok cok cok, em cũng muốn làm cái đó để làm nổi bật các tin bài mới của web nhưng chưa bit làm thế nào? Bác nào giúp e để cho hình ảnh trong bài của em có chữ hot ở góc hình được không ạ? Nó nháy nháy đó Thank ui !!!