########### HTML Helper ########### The HTML Helper file contains functions that assist in working with HTML. .. contents:: :local: .. raw:: html
Loading this Helper =================== This helper is loaded using the following code:: $this->load->helper('html'); Available Functions =================== The following functions are available: .. php:function:: heading([$data = ''[, $h = '1'[, $attributes = '']]]) :param string $data: Content :param string $h: Heading level :param array $attributes: HTML attributes :returns: HTML heading tag :rtype: string Lets you create HTML heading tags. The first parameter will contain the data, the second the size of the heading. Example:: echo heading('Welcome!', 3); The above would produce:

Welcome!

Additionally, in order to add attributes to the heading tag such as HTML classes, ids or inline styles, a third parameter is available:: echo heading('Welcome!', 3, 'class="pink"') The above code produces: .. code-block:: html

Welcome!

.. php:function:: img([$src = ''[, $index_page = FALSE[, $attributes = '']]]) :param string $src: Image source data :param bool $index_page: Whether to treat $src as a routed URI string :param array $attributes: HTML attributes :returns: HTML image tag :rtype: string Lets you create HTML tags. The first parameter contains the image source. Example:: echo img('images/picture.jpg'); // gives There is an optional second parameter that is a TRUE/FALSE value that specifics if the *src* should have the page specified by ``$config['index_page']`` added to the address it creates. Presumably, this would be if you were using a media controller:: echo img('images/picture.jpg', TRUE); // gives Additionally, an associative array can be passed to the ``img()`` function for complete control over all attributes and values. If an *alt* attribute is not provided, CodeIgniter will generate an empty string. Example:: $image_properties = array( 'src' => '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' ); img($image_properties); // Me, demonstrating how to eat 4 slices of pizza at one time .. php:function:: link_tag([$href = ''[, $rel = 'stylesheet'[, $type = 'text/css'[, $title = ''[, $media = ''[, $index_page = FALSE]]]]]]) :param string $href: What are we linking to :param string $rel: Relation type :param string $type: Type of the related document :param string $title: Link title :param string $media: Media type :param bool $index_page: Whether to treat $src as a routed URI string :returns: HTML link tag :rtype: string Lets you create HTML tags. This is useful for stylesheet links, as well as other links. The parameters are *href*, with optional *rel*, *type*, *title*, *media* and *index_page*. *index_page* is a boolean value that specifies if the *href* should have the page specified by ``$config['index_page']`` added to the address it creates. Example:: echo link_tag('css/mystyles.css'); // gives Further examples:: echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); // echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); // Additionally, an associative array can be passed to the ``link()`` function for complete control over all attributes and values:: $link = array( 'href' => 'css/printer.css', 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'print' ); echo link_tag($link); // .. php:function:: ul($list[, $attributes = '']) :param array $list: List entries :param array $attributes: HTML attributes :returns: HTML-formatted unordered list :rtype: string Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:: $list = array( 'red', 'blue', 'green', 'yellow' ); $attributes = array( 'class' => 'boldlist', 'id' => 'mylist' ); echo ul($list, $attributes); The above code will produce this: .. code-block:: html Here is a more complex example, using a multi-dimensional array:: $attributes = array( 'class' => 'boldlist', 'id' => 'mylist' ); $list = array( 'colors' => array( 'red', 'blue', 'green' ), 'shapes' => array( 'round', 'square', 'circles' => array( 'ellipse', 'oval', 'sphere' ) ), 'moods' => array( 'happy', 'upset' => array( 'defeated' => array( 'dejected', 'disheartened', 'depressed' ), 'annoyed', 'cross', 'angry' ) ) ); echo ul($list, $attributes); The above code will produce this: .. code-block:: html .. php:function:: ol($list, $attributes = '') :param array $list: List entries :param array $attributes: HTML attributes :returns: HTML-formatted ordered list :rtype: string Identical to :php:func:`ul()`, only it produces the
    tag for ordered lists instead of