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:

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

 

 

listing 11.1

  1. $mod_headers = [
  2. "backend" => [
  3. "css" => [
  4. [
  5. "media" => "screen",
  6. "file" => "modules/lib_jquery/jquery-ui/jquery-ui.min.css"
  7. ]
  8. ],
  9. "js" => [
  10. "modules/lib_jquery/jquery-ui/jquery-ui.min.js"
  11. ]
  12. ],
  13. "frontend" => [
  14. "css" => [
  15. [
  16. "media" => "screen",
  17. "file" => "template/".DEFAULT_TEMPLATE."/css/special.css"
  18. ],
  19. [
  20. "media" => "print",
  21. "file" => "modules/name/css/print.css"
  22. ]
  23. ],
  24. "js" => [
  25. "modules/lib_jquery/jquery-ui/jquery-ui.min.js"
  26. ]
  27. ]
  28. ];

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

last edit: 12. Mar 2024 CET 21:03:15