Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

custom.css at last position?

If I add:
$Sender->AddCssFile('file.css');
it gets added at the end of all the CSS.

What should be the correct code so that the custom.css will be the last one?

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    To be true: I do not really understand the sorting of the css files in the head. But to my understanding it should be:
    1. styles.css for this is the Vanilla standard
    2. custom.css because it is the master of a custom theme
    3. And then all other plugins css files

    Forcing another sort order doesn't make sense to me. But you can try the following code:

    public function base_beforeAddCss_handler($sender, $args) {
        $args['CssFiles'][] = array(
            'FileName' => 'custom.css',
            'AppFolder' => 'themes/yourtheme',
            'Options' => array(
                '_sort' => 100
            )
        );
    }
    

    But again: doing so feels wrong to me.

  • noncenonce Necro-on Forensics

    you said If I add:$Sender->AddCssFile('file.css'); it gets added at the end of all the CSS.

    if the above option does not work for you.

    then why not add it with a sort option that is lower than the custom.css which seems to be 10

    you would need to fiddle with second parameter.

    addCssFile('file.css', false, ['Sort' => 5]);

    $Sender->addCssFile('file.css', 'plugins/silly', ['Sort' => 5]) );

    depending on your php version you might need the array keyword.

    but again, using specificity might be better then segmenting up css files. this too can be debated.

  • @nonce said:
    but again, using specificity might be better then segmenting up css files. this too can be debated.

    This is correct.

    Aslo make sure you use the the right to add it.

    grep is your friend.

  • LincLinc Detroit Admin

    @Cansili said:
    If I add:
    $Sender->AddCssFile('file.css');
    it gets added at the end of all the CSS.

    What should be the correct code so that the custom.css will be the last one?

    You're probably using the wrong hook. Use assetModel_styleCss_handler($Sender).

Sign In or Register to comment.