Skip to content
Derek Jones edited this page Jul 5, 2012 · 5 revisions

useful php funciton helpers.

<?php
if (! function_exists('load_js')) {
    function load_js($js='') {
        if (empty($js)) {
            return;
        }
        $CI =& get_instance();
        $content = '';
        if (is_array($js)) {
            foreach ($js as $i) {
                $content .= '<script type="text/javascript" src="'.$CI->config->site_url('/scripts/'.$i).'"></script>'."\n";
            }
        } else {
            $content = '<script type="text/javascript" src="'.$CI->config->site_url('/scripts/'.$js).'"></script>'."\n";
        }
        unset($CI);
        return $content;
    }
}

if (! function_exists('load_css')) {
    function load_css($css='', $media='all') {
        if (empty($css)) {
            return;
        }
        $CI =& get_instance();
        $content = '';
        if (is_array($css)) {
            foreach ($css as $i) {
                $content .= '<link type="text/css" rel="stylesheet" href="'.$CI->config->site_url('/styles/'.$i).'" media="'.$media.'" />'."\n";
            }
        } else {
            $content = '<link type="text/css" rel="stylesheet" href="'.$CI->config->site_url('/styles/'.$css).'" media="'.$media.'" />'."\n";
        }
        unset($CI);
        return $content;
    }
}
?>
Clone this wiki locally