slam4:php:phalcon:viewhelpers

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
slam4:php:phalcon:viewhelpers [2016/01/30 17:28] – [Feuilles de style] jcheronslam4:php:phalcon:viewhelpers [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 ====== View Helpers ====== ====== View Helpers ======
  
-La classe [[http://docs.phalconphp.com/en/latest/api/Phalcon_Tag.html|Phalcon\Tag]] fourni un ensemble de méthode facilitant l'écriture des vues, avec phtml ou avec volt.+La classe [[https://api.phalconphp.com/class/Phalcon/Tag.html|Phalcon\Tag]] fourni un ensemble de méthodes facilitant l'écriture des vues, avec phtml ou avec volt.
  
 +Elle est définie en tant que service et est accessible depuis les vues et les controlleurs.
 ===== -- Doctype ===== ===== -- Doctype =====
  
Ligne 19: Ligne 20:
 <sxh php;title:app/views/Index/test.phtml> <sxh php;title:app/views/Index/test.phtml>
 <?php echo $this->tag->getDocType(); <?php echo $this->tag->getDocType();
 +</sxh>
 +
 +<sxh html;title:app/views/Index/test.volt>
 +{{ get_doctype() }}
 </sxh> </sxh>
  
Ligne 46: Ligne 51:
 ===== -- Création de formulaires ===== ===== -- Création de formulaires =====
  
-===== -- Eléments de formulaires =====+==== phtml ====
  
-===== -- Modification des attributs des éléments =====+<sxh php> 
 +<?php 
 +    $this->tag->form(array("products/search", "method" => "get")); 
 +    $this->tag->endForm(); 
 +</sxh>
  
 +==== volt ====
 +
 +<sxh html>
 +{{ form("products/search", "method": "get") }}
 +{{end_form()}}
 +</sxh>
 +===== -- Éléments de formulaires =====
 +
 +==== phtml ====
 +
 +<sxh php>
 +<?php 
 +echo $this->tag->textField("username");
 +
 +echo $this->tag->textArea(array(
 +    "comment",
 +    "This is the content of the text-area",
 +    "cols" => "6",
 +    "rows" => 20
 +));
 +
 +echo $this->tag->passwordField(array(
 +    "password",
 +    "size" => 30
 +));
 +
 +echo $this->tag->hiddenField(array(
 +    "parent_id",
 +    "value"=> "5"
 +));
 +</sxh>
 +
 +==== volt ====
 +
 +<sxh html>
 +{{ text_field("username") }}
 +
 +{{ text_area("comment", "This is the content", "cols": "6", "rows": 20) }}
 +
 +{{ password_field("password", "size": 30) }}
 +
 +{{ hidden_field("parent_id", "value": "5") }}
 +</sxh>
 +===== -- Modification des valeurs des éléments =====
 +
 +Les éléments de formulaire possédant un attribut **value** peuvent être affectés à la création :
 +
 +==== phtml ====
 +
 +<sxh php>
 +<?php 
 +echo $this->tag->textField(array("username",value:"SMITH"));
 +echo $this->tag->textArea(array(
 +    "comment",
 +    "This is the content of the text-area",
 +    "cols" => "6",
 +    "rows" => 20
 +)) ?>
 +</sxh>
 +
 +==== volt ====
 +
 +<sxh html>
 +{{ text_field("username","value":"SMITH") }}
 +
 +{{ text_area("comment", "This is the content", "cols": "6", "rows": 20) }}
 +</sxh>
 +
 +Il est également possible, préférable (pour l'architecture MVC) et inévitable pour certains tags (select par exemple) de faire cette affectation dans le contrôleur :
 +
 +
 +<sxh php;title:app/controllers/ProductsController.php>
 +class ProductsController extends Controller
 +{
 +    public function indexAction()
 +    {
 +        $this->tag->setDefault("username", "SMITH");
 +    }
 +}
 +</sxh>
 ===== -- Contenus statiques ===== ===== -- Contenus statiques =====
  
Ligne 67: Ligne 156:
     {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }}     {{ stylesheet_link("http://fonts.googleapis.com/css?family=Rosario", false) }}
     {{ stylesheet_link("css/style.css") }}     {{ stylesheet_link("css/style.css") }}
 +</sxh>
 +
 +==== javascript file ====
 +=== phtml ===
 +
 +<sxh php>
 +<?php
 +
 +         echo Phalcon\Tag::javascriptInclude("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false);
 +         echo Phalcon\Tag::javascriptInclude("javascript/jquery.js");
 +</sxh>
 +
 +
 +=== volt ===
 +<sxh html>
 + {{ javascript_include("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false) }}
 + {{ javascript_include("javascript/jquery.js") }}
 +</sxh>
 +
 +==== Images ====
 +
 +=== phtml ===
 +
 +<sxh php>
 +<?php
 +
 +         echo Phalcon\Tag::image("img/bg.png");
 +         echo Phalcon\Tag::image(array("img/photo.jpg", "alt" => "Some Photo"));
 +</sxh>
 +
 +=== volt ===
 +
 +<sxh html>
 +
 +         {{ image("img/bg.png") }}
 +         {{ image("img/photo.jpg", "alt": "Some Photo") }}
 +         {{ image("http://static.mywebsite.com/img/bg.png", false) }}
 </sxh> </sxh>
  • slam4/php/phalcon/viewhelpers.1454171338.txt.gz
  • Dernière modification : il y a 6 ans
  • (modification externe)