Welcome Guest, Not a member yet? Register   Sign In
Issue with include
#6

(This post was last modified: 05-17-2016, 12:37 PM by Wouter60.)

I have built my own Assets library. It's autoloaded in autoload.php, so it's available for all pages.
The library his public arrays like $stylesheets and $javascripts.
And methods like add_stylesheet($path), and add_javascript($path).
But also: output_stylesheets(), which just returns a string with all stylesheets in the appropriate format.

In my controller, I do this:
PHP Code:
$this->assets->add_stylesheetbase_url() . 'assets/css/example.css');
$this->assets->add_javascriptbase_url() . 'assets/js/example.js'); 

In my header view I have this:
PHP Code:
<head>
<?= 
$this->assets->output_stylesheets();?>
<?= $this
->assets->output_javascripts();?>
</head> 

The method output_stylesheets in the library is like this:
PHP Code:
public function output_stylesheets()
{
    if (empty(
$this->stylesheets)) return NULL;
    
$str '';
    foreach(
$this->stylesheets AS $item){
        
$str .= '<link rel="stylesheet" href="' $item '" type="text/css" />' "\n";
    }    
    return 
$str;


For me, this is as flexible as I need it.
Reply


Messages In This Thread
Issue with include - by kikk - 05-12-2016, 06:25 AM
RE: Issue with include - by Wouter60 - 05-12-2016, 09:55 AM
RE: Issue with include - by kikk - 05-13-2016, 12:12 AM
RE: Issue with include - by kikk - 05-13-2016, 06:34 AM
RE: Issue with include - by kikk - 05-17-2016, 12:40 AM
RE: Issue with include - by Wouter60 - 05-17-2016, 12:36 PM
RE: Issue with include - by John_Betong - 05-17-2016, 05:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB