-
Book Overview & Buying
-
Table Of Contents
concrete5 Cookbook
In many situations, you will want to avoid writing HTML strings in your PHP server-side code, as it can really clutter your code and make it harder to read. The HTML helper in concrete5 can help you avoid that by providing a nice, object oriented way to generate HTML code.
This recipe assumes that /css/example.css, /js/example.js, and /images/icon.png all exist on your site. You can perform this recipe without those files existing, concrete5 will simply output a path to those non-existent files.
Make the HTML helper available for use:
$html = Loader::helper('html');Output a CSS <link> tag, linking to a CSS file stored at /css/example.css:
echo $html->css('example.css');Output a JavaScript <script> tag, setting the src attribute to a file that exists at /js/example.js:
echo $html->javascript('example.js');Output an image <img> tag, showing an image that is stored at /images/icon.png:
echo $html->image...
Change the font size
Change margin width
Change background colour