Welcome Guest, Not a member yet? Register   Sign In
Placing Assets Q
#1

[eluser]hasokeric[/eluser]
Does anyone have a tut/article to where to place the Assets (js/css/images) and how to link to them inside a page (a view) currently the method i am using is the xhtml tag base href however curious of a better method.

Thanks in advance.
#2

[eluser]t'mo[/eluser]
The functions "site_url" in the URL helper and "link_tag" in the HTML helper come to mind.
#3

[eluser]Thorpe Obazee[/eluser]
You can place them anywhere but personally I just create folders(css/images/js) on the root folder. then I use this helper:

Code:
<?php
/*
* @author        Thorpe Obazee
* @since        Version 1.1
* @license         BSD
*/

if ( ! function_exists('add_stylesheet'))
{
    function add_stylesheet($stylesheets = array())
    {
        if ( ! is_array($stylesheets))
        {
            $stylesheets = array($stylesheets);
        }

        foreach ($stylesheets as $key => $val)
        {
            html_stylesheet($key, $val);
        }
    }
}

if ( ! function_exists('html_stylesheet'))
{
    function html_stylesheet($src, $media)
    {
        echo "<link rel=\"stylesheet\" href=\"".base_url()."$src\" media = \"$media\" type=\"text/css\" />";
    }
}

To use:

Code:
<?php add_stylesheet(array('media/css/styles.css' => 'screen')); ?>




Theme © iAndrew 2016 - Forum software by © MyBB