{Giúp với} Hỏi cách làm chèn hình *.gif (new hoặc hot) vào tiêu đề bài viết

Thảo luận trong 'Hướng dẫn - Hỏi đáp' bắt đầu bởi quangle18, 2/1/12.

  1. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    Thân chào quý anh em
    Nhân dịp năm mới 2012 đến kính chúc quý anh em joomlaviet sức khỏe, thành đạt.
    Hôm nay, quangle18 có vấn đề hỏi, mong anh em chỉ giúp. Gửi lời cảm ơn trước
    neww.
     
    lalang thích bài này.
  2. thaibao3

    thaibao3 Rất tích cực

    Bài viết:
    30
    Likes :
    17
    Vào module bạn muốn thể hiện,thay:
    Mã:
    echo $item->text;
    thành
    Mã:
    echo $item->text."<img src='images/new.gif'/>";
    đưa hình new.gif vào thư mục images.
     
    lalang and quangle18 like this.
  3. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    Bạn ơi ở đây mình muốn tin mới đăng thì hiện hình (new.gif) đó bạn, bạn vui lòng chỉ dùm, chân thành cảm ơn
     
    lalang thích bài này.
  4. thaibao3

    thaibao3 Rất tích cực

    Bài viết:
    30
    Likes :
    17
    Bạn dùng module nào thì thay ở module đó, ví dụ tin mới dung module latestnew
     
    lalang and quangle18 like this.
  5. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    Mình dùng 2 cái nầy
    1. Module như bạn nói mod_latestnews nhưng tìm hoai không thấy chữ echo $item->text;
    2. com_contact trong đây có com hiên thị tin cũ mới. Nhưng làm thế nào thì vẫn không thấy
     
    lalang thích bài này.
  6. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    Không ai hỗ trợ giúp hết thế
     
  7. joomla

    joomla OMG Staff Member

    Bài viết:
    1,068
    Likes :
    2,262
    Trong mod_latestnews, mở file helper.php
    Xuống cuối trang, tìm đến đoạn code:


    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='modules/mod_latestnews/hot.gif'/>";
    $i++;
    }

    return $lists;
    }
    }

    Thê đoạn màu đỏ nhé
    modules/mod_latestnews/hot.gif <-- là file hình của bạn
    Đến đây chắc bạn đã làm đc rùi đúng ko? nếu có khó khắn gì cứ post lên nhé
     
    lalang and quangle18 like this.
  8. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    quá tuyệt! Chân thành cảm ơn joomlaviet.vn
    Nhưng mình đã làm như thế, Mình copy hình hot.gif vào thư mục mod_latestnews luôn rồi nhưng vẫn chưa được. Rất mong được sự chỉ dẫn thêm. Thật sự quangle18 rất vui khi nhận được sự hỗ trợ tích cực của các anh em
     
  9. joomla

    joomla OMG Staff Member

    Bài viết:
    1,068
    Likes :
    2,262
    Ok như này nhé,
    Chi tiết cho 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é
    new.
    Demo: hd.

    Tới đây mình nghĩ chắc bạn sẽ làm đc thôi, nếu có vước mắc gì bạn cứ hỏi, mình cùng giải quyết
    Nhân đây cũng mong bạn sẽ tích cực ủng hộ joomlaviet.vn phát triển, cảm ơn nhiều!
     

    Các file đính kèm:

    lalang and songlanuihong like this.
  10. quangle18

    quangle18 Mới tham gia

    Bài viết:
    23
    Likes :
    5
    Không biết có phải template của mình không hỗ trợ hay sao mà làm đúng như thế mà vẫn không hiệ ra. Mình đang dùm template JA Teline IV. Thành thật làm phiền anh rất nhiều
     
  11. joomla

    joomla OMG Staff Member

    Bài viết:
    1,068
    Likes :
    2,262
    Bạn thử thay template khác xem sao, cái này mình nghĩ ko ảnh hưởng tới template, PM cho mình yahoo: joomla_vietnam mình hỗ trợ cho
     
  12. bibi1

    bibi1 Mới tham gia

    Bài viết:
    29
    Likes :
    0
    vấn đề chèn hình New.gif vào tiêu đề bài viết ở module Latest_News đã ok
    nhưng còn 1 chỗ như này
    khi ở trang chủ thì ở module hiện thị hình new.gif ok
    nhưng khi vào 1 bài viết thì ở module ko hiện hình nữa
    a hỗ trợ giúp nhé
    thanks
     
  13. TomyTran

    TomyTran Marketing & Founder Staff Member

    Bài viết:
    1,073
    Likes :
    666
    Có thể bạn mới chỉ cho hiển thị tại trang chủ hoặc vài trang chứ không phải tất cả và tại vị trí trang trong đó của bạn, bạn quên không chọn cho module này hiển thị ra. Hoặc nếu module hiển thị ra nhưng ảnh hiển thị lỗi thì bạn thử mở source trang đó xem đường dẫn ảnh đã chính xác chưa? có thể ảnh cần nằm ở thư mục images của toàn joomla chứ ko phải của riêng module latest news này.

    Mỗi vấn đề nêu ra cần cụ thể trường hợp của bạn để được ngâm cứu rõ nhất với các thông tin:
    + Mô tả tình trạng lỗi của bạn (càng cụ thể càng tốt, có demo bằng hình ảnh hoặc link nếu có thể nhìn qua link).
    + Đường dẫn đến trang web của bạn.
    + Giao diện bạn đang dùng.
    + Các gói mở rộng (component, Module, Plugin) bạn đã cài thêm.
     
    quangle18 thích bài này.
  14. miaki0512

    miaki0512 Rất tích cực

    Bài viết:
    47
    Likes :
    18
    Quá tuyệt, Đánh dấu cái đã
     
  15. kk01

    kk01 Mới tham gia

    Bài viết:
    2
    Likes :
    0
    Đã làm được, thanks!
     
  16. TomyTran

    TomyTran Marketing & Founder Staff Member

    Bài viết:
    1,073
    Likes :
    666
    có nút Thích ở góc dưới bên phải mỗi bài viết cho bạn cảm ơn nhằm cổ vũ người viết đấy.
     
    quangle18 thích bài này.
  17. lalang

    lalang Mới tham gia

    Bài viết:
    13
    Likes :
    1
    Hi Các anh chị!
    Tôi đã làm theo hướng dẫn nhưng không biết lỗi chỗ nào mà hình ảnh new.gif không hiện ra được?
    Đoạn code của file helper.php đây. Tôi đã đưa hình vào cả 2 vị trí là mục images va module lastestnew nũa mà không ăn thua. Mong các anh chị giúp đỡ. Cám ơn các anh chị nhiều!
    Link web của tôi: http://www.otoxemayviet.vn/

    -----------------------------------------------------------------------------------------------------------------------------------------------------
    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;
    }
    }
     
  18. VJL

    VJL Be like no others ... Staff Member

    Bài viết:
    501
    Likes :
    303
    lalang thích bài này.
  19. VJL

    VJL Be like no others ... Staff Member

    Bài viết:
    501
    Likes :
    303
    lalang thích bài này.
  20. lalang

    lalang Mới tham gia

    Bài viết:
    13
    Likes :
    1
    Cám ơn hoanghai rất nhiều! giờ thì ok rồi!
     
comments powered by Disqus

Chia sẻ trang này