Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ########### |
| 2 | HTML Helper |
| 3 | ########### |
| 4 | |
| 5 | The HTML Helper file contains functions that assist in working with |
| 6 | HTML. |
| 7 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 8 | .. contents:: |
| 9 | :local: |
| 10 | |
| 11 | .. raw:: html |
| 12 | |
| 13 | <div class="custom-index container"></div> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 14 | |
| 15 | Loading this Helper |
| 16 | =================== |
| 17 | |
| 18 | This helper is loaded using the following code:: |
| 19 | |
| 20 | $this->load->helper('html'); |
| 21 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 22 | Available Functions |
| 23 | =================== |
| 24 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 25 | The following functions are available: |
| 26 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 27 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 28 | .. php:function:: heading([$data = ''[, $h = '1'[, $attributes = '']]]) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 29 | |
Adrian Voicu | 0cfe1c3 | 2015-03-12 22:11:06 +0200 | [diff] [blame] | 30 | :param string $data: Content |
| 31 | :param string $h: Heading level |
| 32 | :param mixed $attributes: HTML attributes |
| 33 | :returns: HTML heading tag |
Adrian Voicu | f67b6fd | 2015-03-12 22:13:08 +0200 | [diff] [blame] | 34 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 35 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 36 | Lets you create HTML heading tags. The first parameter will contain the |
| 37 | data, the second the size of the heading. Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 38 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 39 | echo heading('Welcome!', 3); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 40 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 41 | The above would produce: <h3>Welcome!</h3> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 42 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 43 | Additionally, in order to add attributes to the heading tag such as HTML |
Adrian Voicu | f67b6fd | 2015-03-12 22:13:08 +0200 | [diff] [blame] | 44 | classes, ids or inline styles, a third parameter accepts either a string |
| 45 | or an array:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 46 | |
Adrian Voicu | 875d5a1 | 2015-03-12 16:42:50 +0200 | [diff] [blame] | 47 | echo heading('Welcome!', 3, 'class="pink"'); |
Adrian Voicu | 0cfe1c3 | 2015-03-12 22:11:06 +0200 | [diff] [blame] | 48 | echo heading('How are you?', 4, array('id' => 'question', 'class' => 'green')); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 49 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 50 | The above code produces: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 51 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 52 | .. code-block:: html |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 53 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 54 | <h3 class="pink">Welcome!<h3> |
Adrian Voicu | 8e2f83d | 2015-03-12 17:13:47 +0200 | [diff] [blame] | 55 | <h4 id="question" class="green">How are you?</h4> |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 56 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 57 | .. php:function:: img([$src = ''[, $index_page = FALSE[, $attributes = '']]]) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 58 | |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 59 | :param string $src: Image source data |
| 60 | :param bool $index_page: Whether to treat $src as a routed URI string |
| 61 | :param array $attributes: HTML attributes |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 62 | :returns: HTML image tag |
| 63 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 64 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 65 | Lets you create HTML <img /> tags. The first parameter contains the |
| 66 | image source. Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 67 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 68 | echo img('images/picture.jpg'); // gives <img src="http://site.com/images/picture.jpg" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 69 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 70 | There is an optional second parameter that is a TRUE/FALSE value that |
| 71 | specifics if the *src* should have the page specified by |
| 72 | ``$config['index_page']`` added to the address it creates. |
| 73 | Presumably, this would be if you were using a media controller:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 74 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 75 | echo img('images/picture.jpg', TRUE); // gives <img src="http://site.com/index.php/images/picture.jpg" alt="" /> |
| 76 | |
| 77 | Additionally, an associative array can be passed to the ``img()`` function |
| 78 | for complete control over all attributes and values. If an *alt* attribute |
| 79 | is not provided, CodeIgniter will generate an empty string. |
| 80 | |
| 81 | Example:: |
| 82 | |
| 83 | $image_properties = array( |
| 84 | 'src' => 'images/picture.jpg', |
| 85 | 'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time', |
| 86 | 'class' => 'post_images', |
| 87 | 'width' => '200', |
| 88 | 'height'=> '200', |
| 89 | 'title' => 'That was quite a night', |
| 90 | 'rel' => 'lightbox' |
| 91 | ); |
| 92 | |
| 93 | img($image_properties); |
| 94 | // <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 95 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 96 | .. php:function:: link_tag([$href = ''[, $rel = 'stylesheet'[, $type = 'text/css'[, $title = ''[, $media = ''[, $index_page = FALSE]]]]]]) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 97 | |
| 98 | :param string $href: What are we linking to |
| 99 | :param string $rel: Relation type |
| 100 | :param string $type: Type of the related document |
| 101 | :param string $title: Link title |
| 102 | :param string $media: Media type |
| 103 | :param bool $index_page: Whether to treat $src as a routed URI string |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 104 | :returns: HTML link tag |
| 105 | :rtype: string |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 106 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 107 | Lets you create HTML <link /> tags. This is useful for stylesheet links, |
| 108 | as well as other links. The parameters are *href*, with optional *rel*, |
| 109 | *type*, *title*, *media* and *index_page*. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 110 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 111 | *index_page* is a boolean value that specifies if the *href* should have |
| 112 | the page specified by ``$config['index_page']`` added to the address it creates. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 113 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 114 | Example:: |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 115 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 116 | echo link_tag('css/mystyles.css'); |
| 117 | // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" /> |
| 118 | |
| 119 | Further examples:: |
| 120 | |
| 121 | echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); |
| 122 | // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" /> |
| 123 | |
| 124 | echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); |
| 125 | // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" /> |
| 126 | |
| 127 | Additionally, an associative array can be passed to the ``link()`` function |
| 128 | for complete control over all attributes and values:: |
| 129 | |
| 130 | $link = array( |
| 131 | 'href' => 'css/printer.css', |
| 132 | 'rel' => 'stylesheet', |
| 133 | 'type' => 'text/css', |
| 134 | 'media' => 'print' |
| 135 | ); |
| 136 | |
| 137 | echo link_tag($link); |
| 138 | // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 139 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 140 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 141 | .. php:function:: ul($list[, $attributes = '']) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 142 | |
| 143 | :param array $list: List entries |
| 144 | :param array $attributes: HTML attributes |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 145 | :returns: HTML-formatted unordered list |
| 146 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 147 | |
aneasystone | 1738813 | 2015-07-31 14:56:53 +0800 | [diff] [blame] | 148 | Permits you to generate unordered HTML lists from simple or |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 149 | multi-dimensional arrays. Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 150 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 151 | $list = array( |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 152 | 'red', |
| 153 | 'blue', |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 154 | 'green', |
| 155 | 'yellow' |
| 156 | ); |
| 157 | |
| 158 | $attributes = array( |
| 159 | 'class' => 'boldlist', |
| 160 | 'id' => 'mylist' |
| 161 | ); |
| 162 | |
| 163 | echo ul($list, $attributes); |
| 164 | |
| 165 | The above code will produce this: |
| 166 | |
| 167 | .. code-block:: html |
| 168 | |
| 169 | <ul class="boldlist" id="mylist"> |
| 170 | <li>red</li> |
| 171 | <li>blue</li> |
| 172 | <li>green</li> |
| 173 | <li>yellow</li> |
| 174 | </ul> |
| 175 | |
| 176 | Here is a more complex example, using a multi-dimensional array:: |
| 177 | |
| 178 | $attributes = array( |
| 179 | 'class' => 'boldlist', |
| 180 | 'id' => 'mylist' |
| 181 | ); |
| 182 | |
| 183 | $list = array( |
| 184 | 'colors' => array( |
| 185 | 'red', |
| 186 | 'blue', |
| 187 | 'green' |
| 188 | ), |
| 189 | 'shapes' => array( |
| 190 | 'round', |
| 191 | 'square', |
| 192 | 'circles' => array( |
| 193 | 'ellipse', |
| 194 | 'oval', |
| 195 | 'sphere' |
| 196 | ) |
| 197 | ), |
| 198 | 'moods' => array( |
| 199 | 'happy', |
| 200 | 'upset' => array( |
| 201 | 'defeated' => array( |
| 202 | 'dejected', |
| 203 | 'disheartened', |
| 204 | 'depressed' |
| 205 | ), |
| 206 | 'annoyed', |
| 207 | 'cross', |
| 208 | 'angry' |
| 209 | ) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 210 | ) |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 211 | ); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 212 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 213 | echo ul($list, $attributes); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 214 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 215 | The above code will produce this: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 216 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 217 | .. code-block:: html |
| 218 | |
| 219 | <ul class="boldlist" id="mylist"> |
| 220 | <li>colors |
| 221 | <ul> |
| 222 | <li>red</li> |
| 223 | <li>blue</li> |
| 224 | <li>green</li> |
| 225 | </ul> |
| 226 | </li> |
| 227 | <li>shapes |
| 228 | <ul> |
| 229 | <li>round</li> |
| 230 | <li>suare</li> |
| 231 | <li>circles |
| 232 | <ul> |
| 233 | <li>elipse</li> |
| 234 | <li>oval</li> |
| 235 | <li>sphere</li> |
| 236 | </ul> |
| 237 | </li> |
| 238 | </ul> |
| 239 | </li> |
| 240 | <li>moods |
| 241 | <ul> |
| 242 | <li>happy</li> |
| 243 | <li>upset |
| 244 | <ul> |
| 245 | <li>defeated |
| 246 | <ul> |
| 247 | <li>dejected</li> |
| 248 | <li>disheartened</li> |
| 249 | <li>depressed</li> |
| 250 | </ul> |
| 251 | </li> |
| 252 | <li>annoyed</li> |
| 253 | <li>cross</li> |
| 254 | <li>angry</li> |
| 255 | </ul> |
| 256 | </li> |
| 257 | </ul> |
| 258 | </li> |
| 259 | </ul> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 260 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 261 | .. php:function:: ol($list, $attributes = '') |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 262 | |
| 263 | :param array $list: List entries |
| 264 | :param array $attributes: HTML attributes |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 265 | :returns: HTML-formatted ordered list |
| 266 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 267 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 268 | Identical to :php:func:`ul()`, only it produces the <ol> tag for |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 269 | ordered lists instead of <ul>. |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 270 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 271 | .. php:function:: meta([$name = ''[, $content = ''[, $type = 'name'[, $newline = "\n"]]]]) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 272 | |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 273 | :param string $name: Meta name |
| 274 | :param string $content: Meta content |
| 275 | :param string $type: Meta type |
| 276 | :param string $newline: Newline character |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 277 | :returns: HTML meta tag |
| 278 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 279 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 280 | Helps you generate meta tags. You can pass strings to the function, or |
| 281 | simple arrays, or multidimensional ones. |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 282 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 283 | Examples:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 284 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 285 | echo meta('description', 'My Great site'); |
| 286 | // Generates: <meta name="description" content="My Great Site" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 287 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 288 | echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); |
| 289 | // Note the third parameter. Can be "equiv" or "name" |
| 290 | // Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 291 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 292 | echo meta(array('name' => 'robots', 'content' => 'no-cache')); |
| 293 | // Generates: <meta name="robots" content="no-cache" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 294 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 295 | $meta = array( |
| 296 | array( |
| 297 | 'name' => 'robots', |
| 298 | 'content' => 'no-cache' |
| 299 | ), |
| 300 | array( |
| 301 | 'name' => 'description', |
| 302 | 'content' => 'My Great Site' |
| 303 | ), |
| 304 | array( |
| 305 | 'name' => 'keywords', |
| 306 | 'content' => 'love, passion, intrigue, deception' |
| 307 | ), |
| 308 | array( |
| 309 | 'name' => 'robots', |
| 310 | 'content' => 'no-cache' |
| 311 | ), |
| 312 | array( |
| 313 | 'name' => 'Content-type', |
| 314 | 'content' => 'text/html; charset=utf-8', 'type' => 'equiv' |
| 315 | ) |
| 316 | ); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 317 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 318 | echo meta($meta); |
| 319 | // Generates: |
| 320 | // <meta name="robots" content="no-cache" /> |
| 321 | // <meta name="description" content="My Great Site" /> |
| 322 | // <meta name="keywords" content="love, passion, intrigue, deception" /> |
| 323 | // <meta name="robots" content="no-cache" /> |
| 324 | // <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 325 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 326 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 327 | .. php:function:: doctype([$type = 'xhtml1-strict']) |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 328 | |
| 329 | :param string $type: Doctype name |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 330 | :returns: HTML DocType tag |
| 331 | :rtype: string |
Andrey Andreev | 53b8ef5 | 2012-11-08 21:38:53 +0200 | [diff] [blame] | 332 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 333 | Helps you generate document type declarations, or DTD's. XHTML 1.0 |
| 334 | Strict is used by default, but many doctypes are available. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 335 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 336 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 337 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 338 | echo doctype(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 339 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 340 | echo doctype('html4-trans'); // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 341 | |
Derek Jones | 0f0304c | 2013-07-21 11:35:30 -0700 | [diff] [blame] | 342 | The following is a list of doctype choices. These are configurable, and |
| 343 | pulled from application/config/doctypes.php |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 344 | |
Andrey Andreev | 3de130c | 2014-02-07 23:31:49 +0200 | [diff] [blame] | 345 | =============================== =================== ================================================================================================================================================== |
| 346 | Document type Option Result |
| 347 | =============================== =================== ================================================================================================================================================== |
| 348 | XHTML 1.1 xhtml11 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 349 | XHTML 1.0 Strict xhtml1-strict <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 350 | XHTML 1.0 Transitional xhtml1-trans <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 351 | XHTML 1.0 Frameset xhtml1-frame <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> |
| 352 | XHTML Basic 1.1 xhtml-basic11 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"> |
| 353 | HTML 5 html5 <!DOCTYPE html> |
| 354 | HTML 4 Strict html4-strict <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 355 | HTML 4 Transitional html4-trans <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 356 | HTML 4 Frameset html4-frame <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> |
| 357 | MathML 1.01 mathml1 <!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"> |
| 358 | MathML 2.0 mathml2 <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"> |
| 359 | SVG 1.0 svg10 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
| 360 | SVG 1.1 Full svg11 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> |
| 361 | SVG 1.1 Basic svg11-basic <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd"> |
| 362 | SVG 1.1 Tiny svg11-tiny <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd"> |
| 363 | XHTML+MathML+SVG (XHTML host) xhtml-math-svg-xh <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> |
| 364 | XHTML+MathML+SVG (SVG host) xhtml-math-svg-sh <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> |
| 365 | XHTML+RDFa 1.0 xhtml-rdfa-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> |
| 366 | XHTML+RDFa 1.1 xhtml-rdfa-2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"> |
Andrey Andreev | 59f0426 | 2014-02-26 19:04:36 +0200 | [diff] [blame] | 367 | =============================== =================== ================================================================================================================================================== |
| 368 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 369 | .. php:function:: br([$count = 1]) |
Andrey Andreev | 59f0426 | 2014-02-26 19:04:36 +0200 | [diff] [blame] | 370 | |
| 371 | :param int $count: Number of times to repeat the tag |
| 372 | :returns: HTML line break tag |
| 373 | :rtype: string |
| 374 | |
| 375 | Generates line break tags (<br />) based on the number you submit. |
| 376 | Example:: |
| 377 | |
| 378 | echo br(3); |
| 379 | |
| 380 | The above would produce: |
| 381 | |
| 382 | .. code-block:: html |
| 383 | |
| 384 | <br /><br /><br /> |
| 385 | |
| 386 | .. note:: This function is DEPRECATED. Use the native ``str_repeat()`` |
| 387 | in combination with ``<br />`` instead. |
| 388 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 389 | .. php:function:: nbs([$num = 1]) |
Andrey Andreev | 59f0426 | 2014-02-26 19:04:36 +0200 | [diff] [blame] | 390 | |
| 391 | :param int $num: Number of space entities to produce |
| 392 | :returns: A sequence of non-breaking space HTML entities |
| 393 | :rtype: string |
| 394 | |
| 395 | Generates non-breaking spaces ( ) based on the number you submit. |
| 396 | Example:: |
| 397 | |
| 398 | echo nbs(3); |
| 399 | |
| 400 | The above would produce: |
| 401 | |
| 402 | .. code-block:: html |
| 403 | |
| 404 | |
| 405 | |
| 406 | .. note:: This function is DEPRECATED. Use the native ``str_repeat()`` |
Adrian Voicu | 875d5a1 | 2015-03-12 16:42:50 +0200 | [diff] [blame] | 407 | in combination with `` `` instead. |