【问题标题】:css,javascript path recognize in codeignitercss,javascript路径在codeigniter中识别
【发布时间】:2013-06-05 16:31:19
【问题描述】:

我是 Codeigniter 的新手......我有一些基本的想法......但还不够。让我们谈谈这个问题......

我有一个静态网站..它很快就会变成动态的。现在这个静态网站包含 css,css3 在 css forlder,javascript 在 javascript 文件夹中,图像在 images 文件夹中。现在我想将此静态网站设置为 codeigniter .我将包括index.php和其他页面的整个代码以及文件夹(css,javascript.images)复制粘贴到codeigniter的view文件夹中。对于您的所有类型信息,我的index.php页面就是这样.. .

<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="css/reset.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/style.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/slider.css">
<!--<link href='http://fonts.googleapis.com/css?family=Great+Vibes' 
rel='stylesheet' type='text/css'>-->
<script src="<?= base_url() ?>path/images/js/jquery-1.7.min.js"></script>
<script src="<?= base_url() ?>path/images/js/jquery.easing.1.3.js"></script>
<script src="<?= base_url() ?>path/images/js/tms-0.4.1.js"></script>
<script src="<?= base_url() ?>path/images/js/vpb_script.js"></script>
<script src="<?= base_url() ?>path/images/js/pop.js"></script>

<!--start popup window ref-->
<link href="css/colorbox.css" rel="stylesheet" type="text/css" media="all" />
<script src="<?= base_url() ?>path/js/jquery_002.js"></script>
<script>
    $(document).ready(function(){

        $(".image_show").colorbox({rel:'image_show', transition:"fade"});

    });
</script>
<!--end popup window ref-->

<script>
    $(document).ready(function(){                   
        $('.slider')._TMS({
            show:0,
            pauseOnHover:true,
            prevBu:false,
            nextBu:false,
            playBu:false,
            duration:700,
            preset:'fade',
            pagination:true,
            pagNums:false,
            slideshow:8000,
            numStatus:false,
            banners:false,
            waitBannerAnimation:false,
            progressBar:false
        })      
    });
</script>
<style type='text/css'>
/*This will work for chrome */
    #vpb_general_button{
        padding:5px 2px 4px 2px;
    }

/*This will work for firefox*/
@-moz-document url-prefix() {
    #vpb_general_button{
        padding:5px 2px 6px 2px;
    }
}
</style>
<!--[if lt IE 8]>
   <div style=' clear: both; text-align:center; position: relative;'>
     <a href="http://windows.microsoft.com/en-US/
internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode">
       <img  src="http://storage.ie6countdown.com/assets/100/
images/banners/warning_bar_0000_us.jpg" border="0" 
height="42" width="820" alt="You are     using an outdated browser. For a faster, 
safer browsing experience, upgrade for free today." />
    </a>
  </div>
<![endif]-->
<!--[if lt IE 9]>
    <script type="text/javascript" src="js/html5.js"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="css/ie.css">
<![endif]-->
</head>
<body>
<!--<div class="bg-top">-->
<div class="bgr">
<!--==============================Wrapper=================================-->
<div class="wrapper">
<?php 
   include_once('header.php');
   include_once('navigation.php');
   include_once('slider.php');
   include_once('offers.php');
   include_once('invite.php');
   include_once('testimonial.php');
   include_once('special_item.php');
   include_once('footer.php');
   include_once('popup.php');
   ?>

我的控制器就是这样的......

<?php
class Site extends CI_Controller
{
  function home()
 {
    $this->load->view('index');
 }


}

?>

问题是我的网页正在加载但没有设计,可能是找不到 javascript 或 css

我知道我在这里犯了一个错误..bur我无法解决它,请帮我解决它..

【问题讨论】:

标签: codeigniter


【解决方案1】:

文件夹(css、javascript、图像)不应粘贴到 views 文件夹中,而应粘贴到 Code Igniter 的 index.php 所在的文件夹中。 (通常是application 文件夹的父文件夹,即您的站点公共根目录。)

【讨论】:

    【解决方案2】:

    通常我们将所有类似的文件放入应用程序根目录中的“assets”文件夹中,然后确保使用 Asset_Helper 指向这些文件。这就是 CodeIgniter 的建议

    【讨论】:

      【解决方案3】:

      你可以将&lt;?= base_url() ?&gt;添加到你所有的css链接中。

      <link rel="stylesheet" type="text/css" media="screen" 
      href="<?= base_url() ?>path/to/css/reset.css">
      

      【讨论】:

        【解决方案4】:

        有更全面的答案here。您可能需要考虑由于将 css 目录放置在 application/views 目录中而可能发生的权限问题。 在应用程序目录之外创建一个资产目录,并通过将 URL 帮助程序加载到您的控制器中来使用它,例如 this

        【讨论】:

          猜你喜欢
          • 2017-05-03
          • 2021-06-08
          • 2017-04-12
          • 1970-01-01
          • 2018-05-25
          • 2016-09-11
          • 2015-04-19
          • 2020-07-20
          • 1970-01-01
          相关资源
          最近更新 更多