diff --git a/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md b/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md index f07cceaef..fbb0d9e19 100644 --- a/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md +++ b/docs/en/02_Developer_Guides/01_Templates/03_Requirements.md @@ -13,6 +13,10 @@ coding any references in the `
` tag of your template, as it enables a more **mysite/templates/Page.ss** +``` +<% require css("cms/css/TreeSelector.css") %> +<% require themedCSS("TreeSelector") %> +<% require javascript("cms/javascript/LeftAndMain.js") %> ``` [alert] @@ -24,24 +28,48 @@ Requiring assets from the template is restricted compared to the PHP API. It is common practice to include most Requirements either in the *init()*-method of your [controller](../controllers/), or as close to rendering as possible (e.g. in [api:FormField]). +```php +` element, so you can define 'screen' or 'print' for example. +```php +Requirements::css("cms/css/TreeSelector.css", "screen,projection"); ``` ### Javascript Files +```php +Requirements::javascript($path); ``` A variant on the inclusion of custom javascript is the inclusion of *templated* javascript. Here, you keep your JavaScript in a separate file and instead load, via search and replace, several PHP-generated variables into that code. +```php +$vars = array( + "EditorCSS" => "cms/css/editor.css", +); + +Requirements::javascriptTemplate("cms/javascript/editor.template.js", $vars); ``` In this example, `editor.template.js` is expected to contain a replaceable variable expressed as `$EditorCSS`. @@ -53,6 +81,18 @@ of 'configuration' from the database in a raw format. You'll need to use the `h this is generally speaking the best way to do these things - it clearly marks the copy as belonging to a different language. +```php +Requirements::customScript(<<