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