Elgg  Version 4.3
Functions
external_files.php File Reference

Go to the source code of this file.

Functions

 elgg_define_js ($name, $config)
 Helper functions for external files like css/js. More...
 
 elgg_require_js ($name)
 Request that Elgg load an AMD module onto the page. More...
 
 elgg_unrequire_js ($name)
 Cancel a request to load an AMD module onto the page. More...
 
 elgg_require_css (string $view)
 Register a CSS view name to be included in the HTML head. More...
 
 elgg_unrequire_css (string $view)
 Unregister a CSS view name to be included in the HTML head. More...
 
 elgg_register_external_file (string $type, string $name, string $url, string $location= '')
 Core registration function for external files. More...
 
 elgg_unregister_external_file (string $type, string $name)
 Unregister an external file. More...
 
 elgg_load_external_file (string $type, string $name)
 Load an external resource for use on this page. More...
 
 elgg_get_loaded_external_resources (string $type, string $location)
 Get external resource descriptors. More...
 

Function Documentation

elgg_define_js (   $name,
  $config 
)

Helper functions for external files like css/js.

Defines a JS lib as an AMD module. This is useful for shimming traditional JS or for setting the paths of AMD modules.

Calling multiple times for the same name will:

  • set the preferred path to the last call setting a path
  • overwrite the shimmed AMD modules with the last call setting a shimmed module

Use elgg_require_js($name) to load on the current page.

Calling this function is not needed if your JS are in views named like module/name.js Instead, simply call elgg_require_js("module/name").

Note
The configuration is cached in simplecache, so logic should not depend on user- specific values like elgg_get_current_language().
Parameters
string$nameThe module name
array$configAn array like the following: array 'deps' An array of AMD module dependencies string 'exports' The name of the exported module string 'src' The URL to the JS. Can be relative.
Returns
void
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 30 of file external_files.php.

elgg_get_loaded_external_resources ( string  $type,
string  $location 
)

Get external resource descriptors.

Parameters
string$typeType of file: js or css
string$locationPage location
Returns
array
Since
4.3

Definition at line 152 of file external_files.php.

elgg_load_external_file ( string  $type,
string  $name 
)

Load an external resource for use on this page.

Parameters
string$typeType of file: js or css
string$nameThe identifier for the file
Returns
void
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 139 of file external_files.php.

elgg_register_external_file ( string  $type,
string  $name,
string  $url,
string  $location = '' 
)

Core registration function for external files.

Parameters
string$typeType of external resource (js or css)
string$nameIdentifier used as key
string$urlURL
string$locationLocation in the page to include the file (default = 'footer' for js, 'head' for anything else)
Returns
bool
Since
1.8.0
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 109 of file external_files.php.

elgg_require_css ( string  $view)

Register a CSS view name to be included in the HTML head.

Parameters
string$viewThe css view name
Returns
void
Since
3.1
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 75 of file external_files.php.

elgg_require_js (   $name)

Request that Elgg load an AMD module onto the page.

Parameters
string$nameThe AMD module name.
Returns
void
Since
1.9.0

Definition at line 51 of file external_files.php.

elgg_unregister_external_file ( string  $type,
string  $name 
)

Unregister an external file.

Parameters
string$typeType of file: js or css
string$nameThe identifier of the file
Returns
bool
Since
1.8.0

Definition at line 126 of file external_files.php.

elgg_unrequire_css ( string  $view)

Unregister a CSS view name to be included in the HTML head.

Parameters
string$viewThe css view name
Returns
void
Since
3.1

Definition at line 94 of file external_files.php.

elgg_unrequire_js (   $name)

Cancel a request to load an AMD module onto the page.

Parameters
string$nameThe AMD module name.
Returns
void
Since
2.1.0

Definition at line 62 of file external_files.php.