Kênh 360 Công Nghệ Kênh 360 Công Nghệ

Trang chủ - Joomla - Giới thiệu - Hướng dẫn - Chèn CSS external của module Joomla vào template Joomla

Chèn CSS external của module Joomla vào template Joomla

Hướng dẫn chèn Cascading style sheet CSS của một module Joomla vào template Joomla trong Joomla 1.5.
  1. Sao lưu và Mở file helper.php trong thư mục  chứa module của bạn
    /joomla/modules/mod_your_module/joomla/modules/mod_your_module
  2. Thêm hàm addStyleFiles vào class modYour_ModuleHelper
  3. function addStyleFiles () {
    global $mainframe;
    $filename = 'style.css';// Tên file CSS
    $tplpath = DS.'templates'.DS.$mainframe->getTemplate().DS.'css'.DS;
    $tplurl = '/templates/'.$mainframe->getTemplate().'/css/';
    // Đường dẫn tới thư mục template của module
    $modurl = '/modules/mod_your_module/tmpl/';

    $cssurl = $tplurl;
    if(!file_exists(JPATH_SITE.$tplpath.$filename)){
    $cssurl = $modurl;
    }
    $cssurl = JURI::base().$cssurl;
    JHTML::stylesheet ($filename, $cssurl);
    ?>
    <script type="text/javascript">
    //<![CDATA[
    var links = document.getElementsByTagName ('link');
    var included = false;
    if (links.length) {
    for (var i=0;i<links.length;i++) {
    if (links[i].getAttribute('href').test('style.css')) {
    included = true;
    break;
    }
    }
    }
    if (!included) {
    var script = document.createElement('link');
    script.setAttribute('type', 'text/css');
    script.setAttribute('rel', 'stylesheet');
    script.setAttribute('href', '<?php echo $cssurl.$filename; ?>');
    document.getElementsByTagName("head")[0].appendChild(script);
    }
    //]]>
    </script>
    <?php
    }

  4. Triệu gọi phương thức addStyleFiles trong mod_your_module.php
modYour_ModuleHelper::addStyleFiles();
4. Upload file style.css vào thư mục css của template
/templates/your_template/css
Lần cập nhật cuối ( Thứ ba, 07 Tháng 7 2009 14:29 )  

Kênh 360 công nghệ

  • Nổi bật
  • Tin mới
  • Game mới
  • PrestaShop Guide
  • PrestaShop

Có thể bạn quan tâm

Download nhiều nhất

11/12
Download PES 2011 - FIFA 11
693
18/12
binkw32 dll
175
18/12
TeamViewerQS
49
English French German Japanese Korean