Welcome Guest, Not a member yet? Register   Sign In
External v2 - Route Based Asset Management
#1

[eluser]darkhouse[/eluser]
Greetings! I've been off the forums for a while, but I'm back, with a vengeance. I recently rewrote my External library (see previous version).

Here is the link to the new library. https://github.com/darkhouse/External

There were a lot of things I wanted to incorporate into it so I've rewritten it from scratch. Version 2 is based on the same principle that you can specify assets for certain routes, but with some new, I think cool, features. I've explained them in more detail on the wiki, but here's a summary.

Groups - Everything is group based now (inspired by tonydewan's Carabiner) so you can load only assets from a specific group if you want. You can also load assets in more than one place on a page, so you can target different assets for different parts of your page.

Inheritance! - You can specify assets for a route, but also inherit assets from another route.

Exclusions - when inheriting, you can tell it to ignore certain groups.

Weights - you can load the assets in whatever order you want.

LESS.js - I use LESS.js myself, so I've added support for that.

Pretty Output - There is a tabs param so that the output matches the indentation of the rest of your code.

There are more details on the wiki, and some usage code. Also, I've added a sample config file that has the settings I used for a site recently. That should give you a pretty good idea how to setup your config file.

Thanks to everyone who used my original, and I hope this new version helps make things even better.
#2

[eluser]jarthur[/eluser]
Not sure if i'm doing something wrong, but on PHP 5.3 i get the following error/warning:

Quote:Severity: Warning
Message: Parameter 1 to array_multisort() expected to be a reference, value given
Filename: libraries/External.php
Line Number: 325

I think it is related to this: http://bugs.php.net/bug.php?id=43568
#3

[eluser]jarthur[/eluser]
This code change worked for me (starting on line 311 of the External.php file):
Code:
private function _multisort(){
        $args = func_get_args();
        $data = array_shift($args);
                if (!is_array($data))
                    return false;

                $multisort_params = array();
        foreach ($args as $n => $field) {
            if (is_string($field)) {
                ${"tmp_$n"} = array();
                foreach ($data as $key => $row){
                    ${"tmp_$n"}[$key] = $row[$field];
                }
                $multisort_params[$n] = &${"tmp_$n"};
            }
        }
        $multisort_params[] = &$data;
        call_user_func_array('array_multisort',$multisort_params);
        return array_pop($multisort_params);
    }
#4

[eluser]darkhouse[/eluser]
Thanks, I'll make this change - I grabbed that multisort code from php.net, I didn't modify it, and it was working fine for me on v5.3.5
#5

[eluser]darkhouse[/eluser]
I've changed this, and modified the cachebusting system based on CroNiX's suggestion. Thanks guys. I've also added some better documentation, added a markdown readme file which goes over the config file in pretty good detail (I think). As always, if anyone has any questions, please feel free to ask. Thanks!
#6

[eluser]dchankhour[/eluser]
I have issues with sub pages. i have a controller search/advanced with the url http://mydomain.com/search/advanced but the css is being loaded as follow

search/advanced/includes/styles.css

where the link should be just

includes/styles.css

any thoughts on this one?

Thanks
#7

[eluser]darkhouse[/eluser]
dchankhour: are you using a <base> tag?
#8

[eluser]icomefromthenet[/eluser]
might just be use this in my next project, beats hard-coding in controllers thanks for posting.
#9

[eluser]dchankhour[/eluser]
Sorry darkhouse, i'm not sure what you meant by <base>.

I basically have my site in a subfolder. in the site i have a search folder and i have home.php and an advanced.php controller in the search folder. when i view the /search/home every thing works fine but when i view search/advanced it does not load any css files.

it basically try loading http://localhost/mysite/search/includes/styles.css

instead of http://localhost/mystie/includes/styles.css

thanks for your assistance.
#10

[eluser]darkhouse[/eluser]
dchankhour: Right, you need a <base> tag. Put this in your <head>

Code:
<base href="<?php echo base_url(); ?>"></base>

If you're not already loading the url helper, I would autoload it. Just add 'url' to the helper array in application/config/autoload.php and then base_url() will work.




Theme © iAndrew 2016 - Forum software by © MyBB