Adding custom CSS for mod

Started by RRasco, April 20, 2011, 03:07:50 PM

Previous topic - Next topic

RRasco

What is the best practice for adding CSS for a mod?  I am trying to use a psuedo-class to enable a hover effect for table rows.  I can get it working by adding the css to the index.css file, but that seems like a bad idea in that SMF may overwrite it during an upgrade.  Since hover is a psuedo-class, it can't be defined inline, so that's out of the question.  I really don't want to create a CSS file for my mod, but that seems like the only option at this time.  Ideas?
Vehicle Management System for SMF - SMFGarage.com

Arantor

You have two choices.

1. Create a file and drop it into $themedir/css during installation, then call it via loadTemplate(false, 'myfile') in your source file. Note the lack of file extension.

2. Declare it in the page header by adding a <style> block into the header by adding the tag and contents to $context['html_headers'].

RRasco

Interesting.  The first method worked well.  Thanks.

Follow up question to that...does that only load the CSS?  I already have a call to loadTemplate() right before the code you suggested.  Are both of them necessary now?

    loadTemplate('Garage');
    loadTemplate(false, 'garage');
    loadLanguage('Garage');
Vehicle Management System for SMF - SMFGarage.com

Arantor

No, you could use loadTemplate('Garage', 'Garage'); to load the template and CSS at once.

RRasco

Vehicle Management System for SMF - SMFGarage.com

Advertisement: