Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

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 Cheerleader & Troubleshooter Munich Moderator

    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.

    Shadowdarehgtonight
  • 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 Director of Development Detroit Vanilla Staff

    @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).

    hgtonight
Sign In or Register to comment.