Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

config_load

Nombre del Atributo Tipo Requerido Default Descripción
file string Si n/a El nombre del archivo de configuración a incluir
section string No n/a El nombre de la sección a cargar
scope string no local Como el scope carga las variables debe ser tratado de manera local, como padre y no como global. local indica que las variables son cargadas en el contexto del template local. parent indica que las variables son cargadas en el contexto actual y en el template que llamo. global indica que las variables estan disponibles para todos los templates.
global boolean No No Cuando las variables no son vistas en el template padre (al que llamo este), lo mismo que scope=parent. NOTA: este atributo esta obsoleto pero el atributo scope, puede dar el soporte. Si scope es el indicado, este valor es ignorado.

Esta función es usada para cargar las #variables# de un archivo de configuración dentro de un template. Vea Config Files para mayor información.

Example 7.2. Función {config_load}

ejemplo.conf


#this is config file comment

# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00

#customer variables section
[Customer]
pageTitle = "Customer Info"

  

y el template

 
 {config_load file="example.conf"}

 <html>
      <title>{#pageTitle#|default:"No title"}</title>
      <body bgcolor="{#bodyBgColor#}">
     <table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
         <tr bgcolor="{#rowBgColor#}">
             <td>First</td>
             <td>Last</td>
             <td>Address</td>
         </tr>
     </table>
     </body>
 </html>
 
 

Los archivos de configuración pueden contener secciones también. Usted puede cargar variables de una sección adicionando el atributo 'section'.

Note

Config file sections es la función integrada de template {section} no tiene nada que ver uno con el otro, ellos justamente por casualidad tiene en común el convensionalismo del nombre.

Example 7.3. Función config_load con section


{config_load file="ejemplo.conf" section="Customer"}

<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
   <tr bgcolor="{#rowBgColor#}">
      <td>First</td>
      <td>Last</td>
      <td>Address</td>
   </tr>
</table>
</body>
</html>

  

Vea también Config files, Config variables, $config_dir, get_config_vars() y config_load().

Comments
No comments for this page.

Advertisement

Sponsors [info]

Sponsors