From 0f0304c81c8641d373c88d970456e66ebe362ac2 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Sun, 21 Jul 2013 11:35:30 -0700 Subject: Update HTML helper docs --- user_guide_src/source/helpers/html_helper.rst | 597 +++++++++++++------------- 1 file changed, 300 insertions(+), 297 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst index 1016d3bcd..9e9d7ca62 100644 --- a/user_guide_src/source/helpers/html_helper.rst +++ b/user_guide_src/source/helpers/html_helper.rst @@ -5,7 +5,12 @@ HTML Helper The HTML Helper file contains functions that assist in working with HTML. -.. contents:: Page Contents +.. contents:: + :local: + +.. raw:: html + +
Loading this Helper =================== @@ -14,94 +19,95 @@ This helper is loaded using the following code:: $this->load->helper('html'); +Available Functions +=================== + The following functions are available: -br() -==== -.. function:: br($count = 1) +.. function:: br([$count = 1]) :param int $count: Number of times to repeat the tag :returns: string -Generates line break tags (
) based on the number you submit. -Example:: + Generates line break tags (
) based on the number you submit. + Example:: + + echo br(3); + + The above would produce: - echo br(3); + .. code-block:: html -The above would produce:


+


-heading() -========= -.. function:: heading($data = '', $h = '1', $attributes = '') +.. function:: heading([$data = ''[, $h = '1'[, $attributes = '']]]) :param string $data: Content :param string $h: Heading level :param array $attributes: HTML attributes :returns: string -Lets you create HTML heading tags. The first parameter will contain the -data, the second the size of the heading. Example:: + 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); + echo heading('Welcome!', 3); -The above would produce:

Welcome!

+ 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:: + 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"') + echo heading('Welcome!', 3, 'class="pink"') -The above code produces:

Welcome!<

+ The above code produces: -img() -===== + .. code-block:: html -.. function:: img($src = '', $index_page = FALSE, $attributes = '') +

Welcome!

+ + +.. 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: string -Lets you create HTML tags. The first parameter contains the -image source. Example:: - - echo img('images/picture.jpg'); // gives + Lets you create HTML tags. The first parameter contains the + image source. Example:: -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'); // gives - echo img('images/picture.jpg', TRUE); // 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. + 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:: + 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' - ); + $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 + img($image_properties); + // Me, demonstrating how to eat 4 slices of pizza at one time -link_tag() -========== - -.. function:: ling_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE) +.. function:: ling_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 @@ -111,174 +117,175 @@ link_tag() :param bool $index_page: Whether to treat $src as a routed URI string :returns: 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. + 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*. -Example:: + *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. - echo link_tag('css/mystyles.css'); - // gives + Example:: + echo link_tag('css/mystyles.css'); + // gives -Further examples:: + Further examples:: - echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); - // + echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); + // - echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); - // + 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:: + 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' - ); + $link = array( + 'href' => 'css/printer.css', + 'rel' => 'stylesheet', + 'type' => 'text/css', + 'media' => 'print' + ); - echo link_tag($link); - // + echo link_tag($link); + // -nbs() -===== -.. function:: nbs($num = 1) +.. function:: nbs([$num = 1]) :param int $num: Number of space entities to produce :returns: string -Generates non-breaking spaces ( ) based on the number you submit. -Example:: + Generates non-breaking spaces ( ) based on the number you submit. + Example:: + + echo nbs(3); - echo nbs(3); + The above would produce: -The above would produce:: + .. code-block:: html -     +     -ul() and ol() -============= -.. function:: ul($list, $attributes = '') +.. function:: ul($list[, $attributes = '']) :param array $list: List entries :param array $attributes: HTML attributes :returns: string -Permits you to generate ordered or unordered HTML lists from simple or -multi-dimensional arrays. Example:: + 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:: - - -
  • red
  • -
  • blue
  • -
  • green
  • -
  • yellow
  • - - -Here is a more complex example, using a multi-dimensional array:: - - $attributes = array( - 'class' => 'boldlist', - 'id' => 'mylist' - ); - - $list = array( - 'colors' => array( + $list = 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' + 'green', + 'yellow' + ); + + $attributes = array( + 'class' => 'boldlist', + 'id' => 'mylist' + ); + + echo ul($list, $attributes); + + The above code will produce this: + + .. code-block:: html + +
      +
    • red
    • +
    • blue
    • +
    • green
    • +
    • yellow
    • +
    + + 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:: - - -
  • colors -
      -
    • red
    • -
    • blue
    • -
    • green
    • -
    -
  • -
  • shapes -
      -
    • round
    • -
    • suare
    • -
    • circles -
        -
      • elipse
      • -
      • oval
      • -
      • sphere
      • -
      -
    • -
    -
  • -
  • moods -
      -
    • happy
    • -
    • upset -
        -
      • defeated -
          -
        • dejected
        • -
        • disheartened
        • -
        • depressed
        • -
        -
      • -
      • annoyed
      • -
      • cross
      • -
      • angry
      • -
      -
    • -
    -
  • - + ); + + echo ul($list, $attributes); + + The above code will produce this: + + .. code-block:: html + +
      +
    • colors +
        +
      • red
      • +
      • blue
      • +
      • green
      • +
      +
    • +
    • shapes +
        +
      • round
      • +
      • suare
      • +
      • circles +
          +
        • elipse
        • +
        • oval
        • +
        • sphere
        • +
        +
      • +
      +
    • +
    • moods +
        +
      • happy
      • +
      • upset +
          +
        • defeated +
            +
          • dejected
          • +
          • disheartened
          • +
          • depressed
          • +
          +
        • +
        • annoyed
        • +
        • cross
        • +
        • angry
        • +
        +
      • +
      +
    • +
    .. function:: ol($list, $attributes = '') @@ -286,13 +293,11 @@ The above code will produce this:: :param array $attributes: HTML attributes :returns: string -Identical to :func:`ul()`, only it produces the
      tag for -ordered lists instead of
        . + Identical to :func:`ul()`, only it produces the
          tag for + ordered lists instead of
            . -meta() -====== -.. function:: meta($name = '', $content = '', $type = 'name', $newline = "\n") +.. function:: meta([$name = ''[, $content = ''[, $type = 'name'[, $newline = "\n"]]]]) :param string $name: Meta name :param string $content: Meta content @@ -300,109 +305,107 @@ meta() :param string $newline: Newline character :returns: string -Helps you generate meta tags. You can pass strings to the function, or -simple arrays, or multidimensional ones. - -Examples:: - - echo meta('description', 'My Great site'); - // Generates: - - echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); - // Note the third parameter. Can be "equiv" or "name" - // Generates: - - echo meta(array('name' => 'robots', 'content' => 'no-cache')); - // Generates: - - $meta = array( - array( - 'name' => 'robots', - 'content' => 'no-cache' - ), - array( - 'name' => 'description', - 'content' => 'My Great Site' - ), - array( - 'name' => 'keywords', - 'content' => 'love, passion, intrigue, deception' - ), - array( - 'name' => 'robots', - 'content' => 'no-cache' - ), - array( - 'name' => 'Content-type', - 'content' => 'text/html; charset=utf-8', 'type' => 'equiv' - ) - ); - - echo meta($meta); - // Generates: - // - // - // - // - // - -doctype() -========= - -.. function:: doctype($type = 'xhtml1-strict') + Helps you generate meta tags. You can pass strings to the function, or + simple arrays, or multidimensional ones. + + Examples:: + + echo meta('description', 'My Great site'); + // Generates: + + echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); + // Note the third parameter. Can be "equiv" or "name" + // Generates: + + echo meta(array('name' => 'robots', 'content' => 'no-cache')); + // Generates: + + $meta = array( + array( + 'name' => 'robots', + 'content' => 'no-cache' + ), + array( + 'name' => 'description', + 'content' => 'My Great Site' + ), + array( + 'name' => 'keywords', + 'content' => 'love, passion, intrigue, deception' + ), + array( + 'name' => 'robots', + 'content' => 'no-cache' + ), + array( + 'name' => 'Content-type', + 'content' => 'text/html; charset=utf-8', 'type' => 'equiv' + ) + ); + + echo meta($meta); + // Generates: + // + // + // + // + // + + +.. function:: doctype([$type = 'xhtml1-strict']) :param string $type: Doctype name -Helps you generate document type declarations, or DTD's. XHTML 1.0 -Strict is used by default, but many doctypes are available. - -Example:: - - echo doctype(); // - - echo doctype('html4-trans'); // - -The following is a list of doctype choices. These are configurable, and -pulled from application/config/doctypes.php - -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| Doctype | Option | Result | -+===============================+==============================+==================================================================================================================================================+ -| XHTML 1.1 | doctype('xhtml11') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML 1.0 Strict | doctype('xhtml1-strict') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML 1.0 Transitional | doctype('xhtml1-trans') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML 1.0 Frameset | doctype('xhtml1-frame') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML Basic 1.1 | doctype('xhtml-basic11') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| HTML 5 | doctype('html5') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| HTML 4 Strict | doctype('html4-strict') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| HTML 4 Transitional | doctype('html4-trans') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| HTML 4 Frameset | doctype('html4-frame') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| MathML 1.01 | doctype('mathml1') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| MathML 2.0 | doctype('mathml2') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| SVG 1.0 | doctype('svg10') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| SVG 1.1 Full | doctype('svg11') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| SVG 1.1 Basic | doctype('svg11-basic') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| SVG 1.1 Tiny | doctype('svg11-tiny') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML+MathML+SVG (XHTML host) | doctype('xhtml-math-svg-xh') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML+MathML+SVG (SVG host) | doctype('xhtml-math-svg-sh') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML+RDFa 1.0 | doctype('xhtml-rdfa-1') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ -| XHTML+RDFa 1.1 | doctype('xhtml-rdfa-2') | | -+-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ \ No newline at end of file + Helps you generate document type declarations, or DTD's. XHTML 1.0 + Strict is used by default, but many doctypes are available. + + Example:: + + echo doctype(); // + + echo doctype('html4-trans'); // + + The following is a list of doctype choices. These are configurable, and + pulled from application/config/doctypes.php + + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | Doctype | Option | Result | + +===============================+==============================+==================================================================================================================================================+ + | XHTML 1.1 | doctype('xhtml11') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML 1.0 Strict | doctype('xhtml1-strict') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML 1.0 Transitional | doctype('xhtml1-trans') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML 1.0 Frameset | doctype('xhtml1-frame') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML Basic 1.1 | doctype('xhtml-basic11') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | HTML 5 | doctype('html5') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | HTML 4 Strict | doctype('html4-strict') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | HTML 4 Transitional | doctype('html4-trans') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | HTML 4 Frameset | doctype('html4-frame') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | MathML 1.01 | doctype('mathml1') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | MathML 2.0 | doctype('mathml2') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | SVG 1.0 | doctype('svg10') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | SVG 1.1 Full | doctype('svg11') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | SVG 1.1 Basic | doctype('svg11-basic') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | SVG 1.1 Tiny | doctype('svg11-tiny') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML+MathML+SVG (XHTML host) | doctype('xhtml-math-svg-xh') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML+MathML+SVG (SVG host) | doctype('xhtml-math-svg-sh') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML+RDFa 1.0 | doctype('xhtml-rdfa-1') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + | XHTML+RDFa 1.1 | doctype('xhtml-rdfa-2') | | + +-------------------------------+------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ \ No newline at end of file -- cgit v1.2.3-24-g4f1b