News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Need CSS included on a topic page, where to add the code?

Started by Axeia, November 24, 2009, 01:09:11 PM

Previous topic - Next topic

Axeia

I'm working on a mod to do the highlighting for the [code] tags and to do the actual highlighting I need to add a couple a of CSS classes.
I've added the following code to display.php at the very end (but inside) the display() function.

    
//<ServerSideHighlighter>
    
$css file_get_contents(dirname(__FILE__)."/highlighting.css");
    
$context['html_headers'] .= '
           <style type="text/css">        
           '
.$css.'
           </style>'
;
    
//</ServerSideHighlighter>
This can also be seen at http://pastebin.com/d76e1336e (line 1202-1208)

It however does nothing, on a topic page I can't even find the <style bit which should be there even if the file couldn't be found for the $css variable.
So any suggestions to add it elsewhere, I'm doing something wrong, what's going on?

Yes I know - I should add the stylesheet as <link>, I'll do that later on.

Matthew K.


Axeia

Was trying to avoid using theme files as to not cause issues when installing new themes etc.

[edit]
As the problem seems to be $context['html_headers'] getting either set or being overwritten later on, can I use something like

if(isset($_GET['topic']))
      
$context['html_headers'] .= '
           <style type="text/css">        
           '
.$css.'
           </style>'
;

inside Sources/Subs.phps footer_template function?
Does that keep functioning if SEO Friendly urls or Pretty URLs are enabled?

Arantor

Why not include that style code inside MessageIndex.php so it can be added when the theme is executed?
Holder of controversial views, all of which my own.


Advertisement: