我在哪里把图像文件,css,js等在Codeigniter? [英] Where do I put image files, css, js, etc. in Codeigniter?

查看:139
本文介绍了我在哪里把图像文件,css,js等在Codeigniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将css文件夹和图像文件夹放在哪里可以接受?我在思维里面的视图文件夹?但是控制器总是重新路由到基本URL的路径,所以我必须指定.html文件中的路径到它的位置,这是多余的。

Where is it acceptable to put css folders and image file folders? I was thinking inside the view folder? However the controller always reroutes the path to the base url so I have to specify the path in the .html file to where it sits, which is redundant.

推荐答案

我的设置如下:


  • 应用程序


  • assets

    • js

    • imgs


    • application
    • system
    • assets
      • js
      • imgs
      • css

      然后我有一个辅助函数,在我的设置上..类似于:

      I then have a helper function that simply returns the full path to this depending on my setup.. something similar to:

      application / helpers / utility_helper.php:

      function asset_url(){
         return base_url().'assets/';
      }
      



      我通常会在同一个文件中保持类似的常用例程并自动加载与codeigniters自动加载配置。注意:base_url()访问的自动加载网址帮助器。

      I will usually keep common routines similar to this in the same file and autoload it with codeigniters autoload configuration. Note: autoload URL helper for base_url() access.

      application / config / autoload.php: b $ b

      $autoload['helper'] = array('url','utility');
      

      然后,您将可以在整个代码中访问asset_url()。

      You will then have access to asset_url() throughout your code.

      这篇关于我在哪里把图像文件,css,js等在Codeigniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆