Welcome Guest, Not a member yet? Register   Sign In
How to add css styles
#11

[eluser]AgentPhoenix[/eluser]
I thought about doing something like that, but the app I'm working on potentially allows someone to run multiple instances from the same server, so in the interest of giving each instance as much visual control as possible, I've had to put all those assets into the application itself.
#12

[eluser]gunter[/eluser]
agentphoenix: imho, for security reasons I think we don“t put css stuff into the view folder - so that everyone can figure out which framework... thats not good...
#13

[eluser]webdezzo[/eluser]
I think the link_tag() method is a great, along with alot of the other html helpers available, unfortunately for us we have found that a lot of front end developers / creative types that "occasionally" have to edit some of that stuff, don't really like to see php code, and it makes it a lot easier if we just have a standard image tag that they are use to seeing. In a perfect world, creatives would never touch code, and it rarely does happen for us, but there is always that ..... occasional instance.
#14

[eluser]clustermagnet[/eluser]
Guys, I have followed all the examples, and am not able to however load up the included css.

Could it be my .htaccess file?

Thanks!

<link rel="stylesheet" type="text/css" href="/system/application/views/ci.css" />

Also, the base_url breaks the page, will go troubleshoot that next

Thanks
#15

[eluser]clustermagnet[/eluser]
Here is the code of the page from the browser:

***
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>header loaded</title>
<link rel="stylesheet" type="text/css" href="assets/css/ci.css" />
</head>
***

I have created the assets directory alongside with the index.php outside of everything, right in the docroot.

Thanks!!!
#16

[eluser]clustermagnet[/eluser]
Guys, my setup must be incorrect.. i cant figure out a URL to bring up anything but the CI pages...
#17

[eluser]InsiteFX[/eluser]
The best way is to use an asset library.

Phil Sturgeon - Asset Library

But you can create an assets_helper.php
in application/helpers and load it.

Create an assets folder in the root folder with your index.php file.

Code:
/**
* USAGE:
* <?php echo css_url();?>.css_filename
*/

/**
* css URL
*
* Returns the "css_url" item
*
* @access    public
* @return    string
*/
if ( ! function_exists('css_url'))
{
    function css_url()
    {
        $CI =& get_instance();
        return $CI->config->slash_item('base_url') . 'assets/css/';
    }
}

/**
* img URL
*
* Returns the "img_url" item
*
* @access    public
* @return    string
*/
if ( ! function_exists('img_url'))
{
    function img_url()
    {
        $CI =& get_instance();
        return $CI->config->slash_item('base_url') . 'assets/img/';
    }
}

/**
* js URL
*
* Returns the "js_url" item
*
* @access    public
* @return    string
*/
if ( ! function_exists('js_url'))
{
    function js_url()
    {
        $CI =& get_instance();
        return $CI->config->slash_item('base_url') . 'assets/js/';
    }
}

/**
* icons URL
*
* Returns the "icons_url" item
*
* @access    public
* @return    string
*/
if ( ! function_exists('icons_url'))
{
    function icons_url()
    {
        $CI =& get_instance();
        return $CI->config->slash_item('base_url') . 'assets/icons/';
    }
}

InsiteFX
#18

[eluser]Todd Perkins[/eluser]
Just autoload the url helper in config/autoload.php and then link to your assets / images etc via

Code:
<?= base_url(); ?>assets/css/stylesheet.css
#19

[eluser]clustermagnet[/eluser]
Guys, in order to have your own assets/ directory you must include it in your httpd.conf/.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt|assets|)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Now, I will go RTFM about the asset library.

(the mistake above that I made was ... awful lol) i still cant believe it.

Thanks everyone! Everyone's help is greatly appreciated.
#20

[eluser]Unknown[/eluser]
i've view many tutorials and forums. i've tried many method suggested but still the css doesn't load.i'm so stuck right now.. (!_!)

can anyone give a simple explaination on how to do it? btw, i'm a newbie in code igniter. really hope that anyone could help..thank you..




Theme © iAndrew 2016 - Forum software by © MyBB