Ayudante HTML
core/helpers/html.forms.php
El Ayudante HTML contiene funciones para manipular elementos HTML mediante PHP.
Cargando este Asistente
Este asistente es cargado usando el siguiente código:
$this->helper("html");
Las siguientes funciones están disponibles:
a(string $text, string $URL = NULL, bool $external = FALSE, array $attributes = array())
Retorna: @string;
Configura una etiqueta <a> y sus atributos. Ejemplo:
$text = "Link"; $URL = "http://www.example.com"; $attributes = array("id" => "foo", "class" => "bar"); ; print a($text, $URL, FALSE, $attributes); //Prints: <a href="http://www.example.com" id="foo" class="bar"> Link </a>
body(boolean $open = TRUE)
Retorna: @string;
Configura una etiqueta <body> de apertura o cierre. Ejemplo:
print body(TRUE); //Your HTML code here print body(FALSE); //Prints: <body> //Your HTML code here </body> //The parameter $raquo outputs the HTML Entity » if it is set up as TRUE.
bold(string $text, boolean $br)
Retorna: @string;
Configura una etiqueta con la propiedad CSS Bold. Ejemplo:
$text = "Bolded text"; bold($text, TRUE); //Prints: <span class="bold"> Bolded text </span> <br /> //Note that $br parameter outputs an <br /> tag.
br(integer $jumps = 1)
Retorna: @string;
Configura una etiqueta <br>. Ejemplo:
print br(2); //Prints: <br / > <br / >
char(string $char, integer $repeat = 1)
Retorna: @string;
Configura e imprime un caracter UTF-8 una o más veces. Ejemplo:
print char("#", 10); //Prints: ##########
div(string $ID, string $type = "id", string $style = NULL, string $content = NULL)
Retorna: @string;
Configura una etiqueta <div>.
Ejemplo #1:
print div("foo", "id"); //You HTML code here print div(FALSE); //Prints: //Note: If you set the $ID parameter as TRUE, a div tag is opened, but not closed <div id="foo"> //You HTML code here </div>
Ejemplo #2:
print div("foo", "id/class","bg_yellow"); //You HTML code here print div(FALSE); //Prints: //Note: If you set the $ID parameter as TRUE, a div tag is opened, but not closed <div id="foo" class="bg_yellow"> //You HTML code here </div>
Ejemplo #3:
print div("bg_yellow", "class"); //You HTML code here print div(FALSE); //Prints: //Note: If you set the $ID parameter as TRUE, a div tag is opened, but not closed <div class="bg_yellow"> //You HTML code here </div>
docType($type = "XHTML 1.0 Strict")
Retorna: @string;
Configura una declaración <!DOCTYPE>. Ejemplo:
print docType(); //Prints: <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xHTML1/DTD/xHTML1-strict.dtd"> print docType("HTML 5"); //Prints: <!DOCTYPE html>
getHTMLDecode(string $HTML)
Retorna: @string;
Convierte todas las entidades HTML de una cadena a sus caracteres correspondientes. Ejemplo:
$rawText = getHTMLDecode("I'll \"walk\" the <b>dog</b> now"); print $rawText; //Prints: I'll "walk" the <b>dog</b> now
h1(string $text)
Retorna: @string;
Configura una etiqueta <h1>. Ejemplo:
print h1("My Header Text"); //Prints: <h1> My Header Text </h1>
h2(string $text)
Retorna: @string;
Configura una etiqueta <h2>. Ejemplo:
print h2("Foo"); //Prints: <h2> My Header Text </h2>
h3(string $text)
Retorna: @string;
Configura una etiqueta <h3>. Ejemplo:
print h3("Bar"); //Prints: <h3> My Header Text </h3>
img(string $src, string $alt = NULL, string $class = "no-border", array $attributes = NULL)
Retorna: @string;
Configura una etiqueta <img />. Ejemplo:
$src = "http://www.example.com/foo.jpg"; $alt = "Lorem Ipsum"; print img($src, $alt, "no-border", NULL); //Prints: <img src="http://www.example.com/foo.jpg" alt="Lorem Ipsum" class="no-border" />
head(boolean $open = TRUE)
Retorna: @string;
Configura una etiqueta <head>. Ejemplo:
print head(TRUE); print "Foo"; print head(FALSE); //Prints: <head> Foo </head>
HTML(boolean $open = TRUE)
Retorna: @string;
Configura una etiqueta <HTML>. Ejemplo:
print HTML(TRUE); //Your HTML code here print head(FALSE); //Prints: <html xmlns="http://www.w3.org/1999/xhtml" lang="'._webLang.'" xml:lang="'._webLang.'"> //Your HTML code here </html>
p(string $text, string $class = "left")
Retorna: @string;
Configura una etiqueta <p> y su atributo class. Ejemplo:
$text = "Foo"; print p($text); //Prints: <p class="left"> Foo </p>
small(string $text)
Retorna: @string;
Configura una etiqueta <small>. Ejemplo:
$text = "Foo"; print small($text); //Prints: <small class="left"> Foo </small>
span(string $class = NULL, string $text, string $id = NULL)
Retorna: @string;
Configura una etiqueta <span> y su atributo class.
Ejemplo #1:
$text = "Foo"; print span("yellow_bold", $text); //Prints: <span class="yellow_bold"> Foo </span>
Ejemplo #2:
$text = "Foo"; print span(NULL, $text, "fooID"); //Prints: <span id="fooID"> Foo </span>
Ejemplo #3:
$text = "Foo"; print span("yellow_bold", $text, "fooID"); //Prints: <span id="fooID" class="yellow_bold"> Foo </span>
openUl(string $ID = NULL, string $class = NULL)
Retorna: @string;
Configura una etiqueta <span> y su atributo class. Ejemplo:
$ID = "foo"; $class = "bar"; print openUl($ID, $class); //Prints: <ul id="foo" class="bar">
li(string $list)
Retorna: @string;
Configura una etiqueta <li>. Ejemplo:
Puede incluir un arreglo simple como parámetro y cargar uno o múltiples ítems. Ejemplo:
$list[0] = "foo"; $list[1] = "bar"; $list[2] = "baz"; print openUl(); print li($list); print closeUl(); //Prints: <ul> <li> foo </li> <li> bar </li> <li> baz </li> </ul>
Por otra parte, puede incluir múltiples elementos y sus atributos. Ejemplo:
$list[0]["item"] = "foo"; $list[0]["class"] = "lorem"; $list[1]["item"] = "bar"; $list[1]["class"] = "ipsum"; print openUl(); print li($list); print closeUl(); //Prints: <ul> <li class="lorem"> foo </li> <li class="ipsum"> bar </li> </ul>
closeUl()
Retorna: @string;
Configura una etiqueta </li> de cierre. Ejemplo:
$list[0] = "foo"; $list[1] = "bar"; $list[2] = "baz"; print openUl(); print li($list); print closeUl(); //Prints: <ul> <li> foo </li> <li> bar </li> <li> baz </li> </ul>
ul(string $list, string $ID = NULL, string $class = NULL)
Retorna: @string;
Configura una bloque <ul> y sus elementos <li>. Ejemplo:
Puede incluir un arreglo simple como parámetro y cargar uno o múltiples ítems. Ejemplo:
$list[0]["item"] = "foo"; $list[0]["class"] = "bar"; $list[1]["item"] = "baz"; $list[1]["class"] = "ban"; $class = "lorem"; $id = "ipsum"; print ul($list, $ID, $class); //Prints: <ul> <li class="bar"> foo </li> <li class="ban"> baz </li> </ul>