Pinegrow Community Support Forum

Adding an external resource conditionally


Hi guys,

another one:

Having this for loading an external stylesheet:

var res = new PgComponentTypeResource('');
res.type = 'text/css';

That’s fine - however it appends it to all already existing sheets. Especially the default style.css . But it necessarily should load before the style.css (supposed for overwrite the external one).

If you could be so kind pointing me here as well into the correct direction.

Thanks in advance.




you can use hasDetect on your new pgFramework Object if

              f = new pgFramework 
              f.detect = function(check){
                    return check.hasScript(put here script name); <<< this function will get a regular expersions or script name.


Thanks @itsmeleo

I have already this one in the plugin-script (adopted from the 960 grid example from @matjaz) but I’m certainly not really understanding it:

   //Auto detect 960 grid. It can also be manually added / removed from a page with Framework Manager
    f.detect = function (pgPage) {
        return pgPage.hasStylesheet(/(^|\/)960.*\.(css|less)/i);

Is it there to adjust the path?




You have to change the RegEx here its only detecting 960grid if this css is added already so replace 960 with your css or add 960 in the name of your styles so they will get detected.