Custom Edit-Mode Styles for Block Dialog?

Permalink
What's the recommended way to apply custom styles to the dialog content when adding or editing a block _without_ using inline styles? Is there some equivalent to the rendered view's view.css file? IOW, can I add a stylesheet reference to the doc head somehow for styling my block's edit dialog?

Thanks,

-Steve

Shotster
 
Shotster replied on at Permalink Reply
Shotster
"IOW, can I add a stylesheet reference to the doc head somehow for styling my block's edit dialog?"

You can of course copy any of the style sheets from the concrete/css directory to the root css directory to override them. However, if you have some block-specific styles you want to apply and don't want to use inline styles, here's a nifty trick...

Using JavaScript, simply add an external stylesheet reference to the document head, which will then be loaded and applied. This can be done with the jQuery library that ships with C5. So, in your block's add.php or edit.php file, just do something like:

<?php
$h = Loader::helper('html');
$s = $h->css('mystyles.css', 'my_package');
?>

<script type="text/javascript">
//<![CDATA[
$('head').append('<?php echo $s; ?>');
//]]>
</script>

-Steve
Shotster replied on at Permalink Reply
Shotster
The only problem is that the style sheet gets added each time the dialog for your block loads, so you'd have to implement a check of some kind to prevent multiple loads.

-Steve
Shotster replied on at Permalink Reply
Shotster
BTW, it'd be "cleaner" IMO to be able to do this from the auto.js file as opposed to using an embedded script, but that means the file would need to be parsed server-side, which leads to my question...

What do the C5 folks think about having C5 check for an auto.js.php file? That would allow server-side code in the JS file while keeping the script separate from the mark-up.

-Steve