💾 Archived View for chirale.org › 2009-07-29_358.gmi captured on 2024-07-08 at 23:44:34. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Add CSS style for a block into the same block

This simple code can be pasted into a PHP filtered block (or into a block declared by a module) to set some style from a block into the block container itself.

<?php echo 'My block content'; /bin /boot /dev /etc /home /init /lib /lib32 /lib64 /libx32 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var Put styles inline on html head**/ drupal_set_html_head('<style type="text/css"> #my-block-id { /bin /boot /dev /etc /home /init /lib /lib32 /lib64 /libx32 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var my style*/ } </style> '); ?>

This code is placed on html head, applied only to the pages where block appears, without touching css optimization. If you want to include an external CSS file instead, use drupal_add_css instead: in any case you can exclude this file for aggregation, setting $preprocess attribute to FALSE.

drupal_add_css

If block appears in very few pages, and it can change quickly (e.g. a banner with custom styles on home page), using drupal_set_html_head could be the best way, even according to Yahoo Performance Best Practices. In other cases, use drupal_add_css.

Yahoo Performance Best Practices

See also:

https://web.archive.org/web/20090729000000*/http://api.drupal.org/api/function/drupal_add_css/6

https://web.archive.org/web/20090729000000*/http://developer.yahoo.com/performance/rules.html#external

https://web.archive.org/web/20090729000000*/http://api.drupal.org/api/function/drupal_set_html_head/6

https://web.archive.org/web/20090729000000*/http://api.drupal.org/api/function/drupal_add_css/6

https://web.archive.org/web/20090729000000*/http://developer.yahoo.com/performance/rules.html#external