feel free to keep it strictly simple...
headers.inc

If more include files are needed in the header, you may define them in the file headers.inc.php. It is also possible to do some checks in advance to load files only if needed to spare bandwidth.

Example: The module MPForm includes a popup calender with a quite large CSS file. Using an appropriate headers.inc.php, it is possible to check if the calendar is used on the current page, and to only load the CSS if really needed.

The definitions are made as a multidimensional array with name $mod_headers.

Example:

 

 

    $mod_headers = array(
		'backend' => array(
			'meta'	=> array(
				"<meta name='Author' content='Peter Jackson Jr.' />"
			),
		    'css' => array(
				array(
					'media'	=> 'screen',
					'file'	=> 'modules/lib_jquery/jquery-ui/jquery-ui.min.css'
				)
			),
			'js'	=> array(
				"modules/lib_jquery/jquery-ui/jquery-ui.min.js"
			)
		),


		
		'frontend' => array(
			'meta'	=> array(
				"<meta name='Author' content='J.R.R.R. Mustermann' />"
			),
		    'css' => array(
				array(
					'media'	=> 'screen',
					'file'	=> 'template/'.DEFAULT_TEMPLATE.'/css/special.css'
				),
				array(
					'media'	=> 'print',
					'file'	=> 'modules/name/css/print.css'
				)
			),
			'js'	=> array(
				"modules/lib_jquery/jquery-ui/jquery-ui.min.js"
			)
		)
	);

 

Note: Of course, the entry for frontend.css is not needed here, as this file is loaded anyway.

 

 

 

Key Type Description
frontend multidimensional Array Define if 'frontend' or 'backend'.
css multidimensional Array List of (additional) CSS files
media String HTML attribute "media"; see http://de.selfhtml.org/css/formate/einbinden.htm#link_media
file String File name without path. If you place your CSS files in a subdirectory ('css', for example), set this to the relative path: 'file' => 'modules/name/print.css'
js Array List of (additional) JavaScript files, see example above
meta Array List of META tags; used "as is", set the complete HTML here. See example above

 

 

Tips & Tricks: Conditional Loading

It is also possible to do some checks in advance to load files only if needed to spare bandwidth.

Example: The module MPForm includes a popup calender with a quite large CSS file. Using an appropriate headers.inc.php, it is possible to check if the calendar is used on the current page, and to only load the CSS if really needed.

 

 

?php 
    $mod_headers = array( ...Standardangaben... );
    global $database, $current_section;
    $res = $database->query( 'SELECT COUNT("type") FROM '.TABLE_PREFIX.'mod_mpform_fields WHERE section_id="'.$current_section.'" AND type="date"' );
    if ( $res->numRows() > 0 ) {
      $mod_headers['frontend']['css'][] = array( 'media' => 'all', 'file' => 'css/calendar.css' );
    }
  ?