HTML Helper
HTML 헬퍼는 HTML관련작업에 유용한 함수를 포함합니다.
Loading this Helper
다음과같이 헬퍼를 로드합니다:
$this->load->helper('html');
다음 함수들이 사용가능 합니다:
br()
설정하신 숫자만큼 <br /> 태그를 생성합니다. 예:
echo br(3);
위코드는 다음을 생성합니다: <br /><br /><br />
heading()
<h1> 태그를 생성합니다. 첫번째 파라미터는 데이터, 두번째 파라미터는 글자 크기를 지정합니다. 예:
echo heading('Welcome!', 3);
위 코드는 다음을 생성합니다: <h3>Welcome!</h3>
img()
<img /> 태그를 생성합니다. 첫번째 파라미터로 이미지 소스를 지정합니다. 예:
echo img('images/picture.jpg');
// gives <img src="http://site.com/images/picture.jpg" />
옵션인 두번째 파라미터는 src주소에 $config['index_page']에 정의된 페이지를 포함해야할지 말지를 정의하는 TRUE/FALSE 값입니다. 미디어 컨트롤러(media controller)를 사용하실경우 필요하실것입니다.
echo img('images/picture.jpg', TRUE);
// gives <img src="http://site.com/index.php/images/picture.jpg" />
추가적으로,모든 속성(attributes) 및 값(values)을 설정하기 위해서 img() 함수에 연관배열을 넘겨줄수 있습니다.
 $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);
	// <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()
<link /> 태그를 만듦니다.  이 함수는 스타일시트(stylesheet)링크 작성시 유용합니다. 파라미터는 href 이며 ,옵션으로 rel, type, title, media 그리고 index_page 를 설정할 수 있습니다. index_page 는  주소에  $config['index_page']에 정의된 페이지를 포함해야할지 말지를 정의하는 TRUE/FALSE 값입니다.
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" /> 
	
	
	echo link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
	// <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" /> 
추가적으로 ,모든 속성(attributes) 및 값(values)을 설정하기 위해서 link() 함수에 연관배열을 넘겨줄수 있습니다.
	$link = array(
	          '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" />
nbs()
파라미터로 넘어온 숫자만큼   를 생성합니다.예:
echo nbs(3);
위 코드는 다음을 생성합니다:    
ol() and ul()
단순배열 혹은 다차원배열로 부터 순서(ordered) 혹은 비순서(unordered) 리스트를 생성합니다. 예:
$this->load->helper('html');
$list = array(
            'red', 
            'blue', 
            'green',
            'yellow'
            );
$attributes = array(
                    'class' => 'boldlist',
                    'id'    => 'mylist'
                    );
echo ul($list, $attributes);
위코드는 아래를 생성합니다:
<ul class="boldlist" id="mylist">
  <li>red</li>
  <li>blue</li>
  <li>green</li>
  <li>yellow</li>
</ul>
다차원배열을 이용한 보다 복잡한 예제입니다:
$this->load->helper('html');
$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);
위 코드는 아래를 생성합니다:
<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>
</ul>
meta()
메타태그를 생성합니다.문자열이나 단순한 배열 또는 다차원배열을 넘겨줍니다. 예:
echo meta('description', 'My Great site');
// Generates:  <meta name="description" content="My Great Site" />
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter.  Can be "equiv" or "name"
// Generates:  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
// Generates:  <meta name="robots" content="no-cache" />
$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:  
// <meta name="robots" content="no-cache" />
// <meta name="description" content="My Great Site" />
// <meta name="keywords" content="love, passion, intrigue, deception" />
// <meta name="robots" content="no-cache" />
// <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
doctype()
다양한 종류의 document type을 생성하도록 도와줍니다.
echo doctype();
// <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
echo doctype('html4-trans');
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
아래는 doctype의 리스트 입니다. 이것들은 application/config/doctypes.php 에서 변경가능합니다.
| Doctype | Option | Result | 
|---|---|---|
| XHTML 1.1 | doctype('xhtml11') | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | 
| 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"> | 
| 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"> | 
| 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"> | 
| HTML 5 | doctype('html5') | <!DOCTYPE html> | 
| HTML 4 Strict | doctype('html4-strict') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | 
| HTML 4 Transitional | doctype('html4-trans') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | 
| HTML 4 Frameset | doctype('html4-frame') | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> | 
