$_jshead
$_jshead : array
Array with all JavaScript declarations for the page's head.
Helper functions for managing HTML head
add_jsfile(string $url, boolean $prepend = false)
Register JavaScript File for referring in the page.
This allows MidCOM components to register JavaScript code during page processing. The site style code can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced, if you want a JScript clean site, just omit the print calls and you should be fine in almost all cases.
The sequence of the add_jsfile and add_jscript commands is kept stable.
string | $url | The URL to the file to-be referenced. |
boolean | $prepend | Whether to add the JS include to beginning of includes |
add_jscript(string $script, $defer = '', $prepend = false)
Register JavaScript Code for output directly in the page.
This allows components to register JavaScript code during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced
The sequence of the add_jsfile and add_jscript commands is kept stable.
string | $script | The code to be included directly in the page. |
$defer | ||
$prepend |
add_jquery_state_script(string $script, string $state = 'document.ready')
Register JavaScript snippets to jQuery states.
This allows components to register JavaScript code to the jQuery states. Possible ready states: document.ready
string | $script | The code to be included in the state. |
string | $state | The state where to include the code to. Defaults to document.ready |
add_object_head(string $script, array $attributes = null)
Register some object tags to be added to the head element.
This allows components to register object tags to be placed in the head section of the page.
string | $script | The input between the tags. |
array | $attributes | Array of attribute=> value pairs to be placed in the tag. |
add_meta_head(array $attributes = null)
Register a metatag to be added to the head element.
This allows components to register metatags to be placed in the head section of the page.
array | $attributes | Array of attribute => value pairs to be placed in the tag. @see print_head_elements() |
add_style_head(string $script, array $attributes = null)
Register a styleblock / style link to be added to the head element.
This allows components to register extra CSS sheets they wants to include. in the head section of the page.
string | $script | The input between the tags. |
array | $attributes | Array of attribute=> value pairs to be placed in the tag. |
add_link_head(array $attributes)
Register a link element to be placed in the page head.
This allows components to register extra CSS links.
Example to use this to include a CSS link:
$attributes = array ('rel' => 'stylesheet',
'type' => 'text/css',
'href' => '/style.css'
);
midcom::get()->head->add_link_head($attributes);
Each URL will only be added once. When trying to add the same URL a second time, it will be moved to the end of the stack, so that CSS overrides behave as the developer intended
array | $attributes | Array of attribute => value pairs to be placed in the tag. |
add_jsonload(string $method)
Register a JavaScript method for the body onload event
This allows components to register JavaScript code during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note that these suggestions are not enforced.
string | $method | The name of the method to be called on page startup, including parameters but excluding the ';'. |
print_jsonload()
Echo the registered javascript code.
This allows components to register JavaScript code during page processing. The site style code can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY-tag. Note, that these suggestions are not enforced
The sequence of the add_jsfile and add_jscript commands is kept stable.
This is usually called during the BODY region of your style:
print_head_elements()
Echo the _head elements added.
This function echos the elements added by the add_(style|meta|link|object)_head methods.
Place the method within the
section of your page.This allows components to register HEAD elements during page processing. The site style can then query this queued-up code at anytime it likes. The queue-up SHOULD be done during the code-init phase, while the print_head_elements output SHOULD be included in the HTML HEAD area and the HTTP onload attribute returned by print_jsonload SHOULD be included in the BODY tag. Note that these suggestions are not enforced