Skip to main content

files

On a couple occasions I found it necessary to generate and save a file from within a module or theme. The last time it was to create a custom stylesheet based on values from theme settings, so I'll use that in my example on how you can do the same. The first thing to do, of course, is to alter the system theme settings form with your custom fields using hook_form_system_theme_settings_alter(). We'll create one field to change the background color of the body and add a custom submit handler to take care generating the custom stylesheet.