summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/helpers/html_helper.rst
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/helpers/html_helper.rst')
-rw-r--r--user_guide_src/source/helpers/html_helper.rst296
1 files changed, 168 insertions, 128 deletions
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 17c28cd2a..df53ebd2f 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -19,6 +19,11 @@ The following functions are available:
br()
====
+.. php:function:: br($count = 1)
+
+ :param int $count: Number of times to repeat the tag
+ :returns: string
+
Generates line break tags (<br />) based on the number you submit.
Example::
@@ -29,7 +34,14 @@ The above would produce: <br /><br /><br />
heading()
=========
-Lets you create HTML <h1> tags. The first parameter will contain the
+.. php: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::
echo heading('Welcome!', 3);
@@ -37,9 +49,7 @@ data, the second the size of the heading. Example::
The above would produce: <h3>Welcome!</h3>
Additionally, in order to add attributes to the heading tag such as HTML
-classes, ids or inline styles, a third parameter is available.
-
-::
+classes, ids or inline styles, a third parameter is available::
echo heading('Welcome!', 3, 'class="pink"')
@@ -48,28 +58,31 @@ The above code produces: <h3 class="pink">Welcome!<<h3>
img()
=====
-Lets you create HTML <img /> tags. The first parameter contains the
-image source. Example
+.. 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: string
+
+Lets you create HTML <img /> tags. The first parameter contains the
+image source. Example::
echo img('images/picture.jpg'); // gives <img src="http://site.com/images/picture.jpg" />
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.
-
-::
+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 <img src="http://site.com/index.php/images/picture.jpg" alt="" />
-Additionally, an associative array can be passed to the img() function
-for complete control over all attributes and values. If an alt attribute
+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',           
@@ -81,128 +94,136 @@ is not provided, CodeIgniter will generate an empty string.
'rel' => 'lightbox'
);
- img($image_properties); // <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" />
+ img($image_properties);
+ // <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" />
link_tag()
-===========
+==========
-Lets you create HTML <link /> 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 TRUE/FALSE value
-that specifics if the href should have the page specified by
-$config['index_page'] added to the address it creates.
+.. php: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
+ :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: string
- echo link_tag('css/mystyles.css'); // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
+Lets you create HTML <link /> 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::
-Further examples
+ echo link_tag('css/mystyles.css');
+ // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
-::
- echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
+Further examples::
- echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
+ echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');
+ // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
-Additionally, an associative array can be passed to the link() function
-for complete control over all attributes and values.
+ echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
+ // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="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'
+ 'href' => 'css/printer.css',
+ 'rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'media' => 'print'
);
- echo link_tag($link); // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
-
+ echo link_tag($link);
+ // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
nbs()
=====
-Generates non-breaking spaces (&nbsp;) based on the number you submit.
-Example
+.. php:function:: nbs($num = 1)
-::
+ :param int $num: Number of space entities to produce
+ :returns: string
- echo nbs(3);
+Generates non-breaking spaces (&nbsp;) based on the number you submit.
+Example::
-The above would produce
+ echo nbs(3);
-::
+The above would produce::
&nbsp;&nbsp;&nbsp;
-ol() and ul()
+ul() and ol()
=============
-Permits you to generate ordered or unordered HTML lists from simple or
-multi-dimensional arrays. Example
+.. php:function:: ul($list, $attributes = '')
-::
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
- $this->load->helper('html');
+Permits you to generate ordered or unordered HTML lists from simple or
+multi-dimensional arrays. Example::
- $list = array(             
- 'red',             
- 'blue',             
- 'green',             
- 'yellow'             
+ $list = array(
+ 'red',
+ 'blue',
+ 'green',
+ 'yellow'
);
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                    
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
echo ul($list, $attributes);
-The above code will produce this
-
-::
+The above code will produce this::
- <ul class="boldlist" id="mylist">   
- <li>red</li>   
- <li>blue</li>   
- <li>green</li>   
+ <ul class="boldlist" id="mylist">
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
<li>yellow</li>
</ul>
-Here is a more complex example, using a multi-dimensional array
-
-::
-
- $this->load->helper('html');
+Here is a more complex example, using a multi-dimensional array::
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                     
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
- $list = array(             
- 'colors' => array(                                 
- 'red',                                 
- 'blue',                                 
- 'green'                             
+ $list = array(
+ 'colors' => array(
+ 'red',
+ 'blue',
+ 'green'
),
- 'shapes' => array(                                 
- 'round',                                 
- 'square',                                 
- 'circles' => array(                                             
+ 'shapes' => array(
+ 'round',
+ 'square',
+ 'circles' => array(
'ellipse',
'oval',
'sphere'
- )                             
- ),             
- 'moods' => array(                                 
- 'happy',                                 
- 'upset' => array(                                         
+ )
+ ),
+ 'moods' => array(
+ 'happy',
+ 'upset' => array(
'defeated' => array(
- 'dejected',                
+ 'dejected',
'disheartened',
'depressed'
),
@@ -215,59 +236,74 @@ Here is a more complex example, using a multi-dimensional array
echo ul($list, $attributes);
-The above code will produce this
-
-::
-
- <ul class="boldlist" id="mylist">   
- <li>colors     
- <ul>       
- <li>red</li>       
- <li>blue</li>       
- <li>green</li>     
- </ul>   
- </li>   
- <li>shapes     
- <ul>       
- <li>round</li>       
- <li>suare</li>       
- <li>circles         
- <ul>           
- <li>elipse</li>           
- <li>oval</li>           
- <li>sphere</li>         
- </ul>       
- </li>     
- </ul>   
- </li>   
- <li>moods     
- <ul>       
- <li>happy</li>       
- <li>upset         
- <ul>           
- <li>defeated             
- <ul>               
+The above code will produce this::
+
+ <ul class="boldlist" id="mylist">
+ <li>colors
+ <ul>
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
+ </ul>
+ </li>
+ <li>shapes
+ <ul>
+ <li>round</li>
+ <li>suare</li>
+ <li>circles
+ <ul>
+ <li>elipse</li>
+ <li>oval</li>
+ <li>sphere</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>moods
+ <ul>
+ <li>happy</li>
+ <li>upset
+ <ul>
+ <li>defeated
+ <ul>
<li>dejected</li>
<li>disheartened</li>
<li>depressed</li>
</ul>
</li>
<li>annoyed</li>
- <li>cross</li>           
- <li>angry</li>         
- </ul>       
- </li>     
- </ul>   
+ <li>cross</li>
+ <li>angry</li>
+ </ul>
+ </li>
+ </ul>
</li>
</ul>
+.. php:function:: ol($list, $attributes = '')
+
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Identical to :php:func:`ul()`, only it produces the <ol> tag for
+ordered lists instead of <ul>.
+
meta()
======
+.. php:function:: meta($name = '', $content = '', $type = 'name', $newline = "\n")
+
+ :param string $name: Meta name
+ :param string $content: Meta content
+ :param string $type: Meta type
+ :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
+simple arrays, or multidimensional ones.
-::
+Examples::
echo meta('description', 'My Great site');
// Generates: <meta name="description" content="My Great Site" />
@@ -279,7 +315,7 @@ simple arrays, or multidimensional ones. Examples
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
// Generates: <meta name="robots" content="no-cache" />
- $meta = array(         
+ $meta = array(
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -291,7 +327,7 @@ simple arrays, or multidimensional ones. Examples
array(
'name' => 'keywords',
'content' => 'love, passion, intrigue, deception'
- ),         
+ ),
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -313,10 +349,14 @@ simple arrays, or multidimensional ones. Examples
doctype()
=========
+.. php: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(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">