Home » Forum
NoNumber!

Joomla! Extensions •
Web Development •
Web Design •

I try to respond within 24 hours (excluding weekends). If I haven't responded by then, feel free to post a reminder or bug me via email.
Welcome, Guest
Please Login or Register.    Lost Password?

How to add CSS to the head of the html page
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: How to add CSS to the head of the html page
#5175
How to add CSS to the head of the html page 8 Months, 3 Weeks ago  
For a piece of css code, use:
{source}<?php
    $css = 'your css...';
    $doc =& JFactory::getDocument();
    $doc->addStyleDeclaration( $css );
?>{/source}

To add a css file to the head, use:
{source}<?php
    $doc =& JFactory::getDocument();
    $doc->addStyleSheet( JURI::root( true ).'/path/to/your/file.css' );
?>{/source}



To add multiple stylesheets/scripts, you can place 1 php block like:
{source}<?php
    $doc =& JFactory::getDocument();

    $css = 'your css...';
    $doc->addStyleDeclaration( $css );

    $doc->addStyleSheet( JURI::root( true ).'/path/to/your/file.css' );
    $doc->addStyleSheet( JURI::root( true ).'/path/to/your/file2.css' );

    $script = 'your script...';
    $doc->addScriptDeclaration( $script );

    $doc->addScript( JURI::root( true ).'/path/to/your/file.js' );
    $doc->addScript( JURI::root( true ).'/path/to/your/file2.js' );
?>{/source}
Peter van Westen
Admin
Posts: 4280
User OfflineClick here to see the profile of this user
Last Edit: 2010/05/06 12:17 By peter.
The topic has been locked.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! NºNumber!NºNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
Go to topPage: 1
Joomla Open Source Training