Foros del Web » Creando para Internet » Sistemas de gestión de contenidos »

[SOLUCIONADO] Cómo hacer plantilla con Flexy template engine?

Estas en el tema de Cómo hacer plantilla con Flexy template engine? en el foro de Sistemas de gestión de contenidos en Foros del Web. Cómo estamos todos! Me bajé una tienda virtual llamada x-Cart . Si uno quiere hacer su propio template, x-Cart nos dice en su tutorial que ...
  #1 (permalink)  
Antiguo 28/03/2014, 16:27
Avatar de berkeleyPunk  
Fecha de Ingreso: febrero-2013
Ubicación: México :C
Mensajes: 565
Antigüedad: 11 años, 2 meses
Puntos: 22
Pregunta Cómo hacer plantilla con Flexy template engine?

Cómo estamos todos!


Me bajé una tienda virtual llamada x-Cart. Si uno quiere hacer su propio template, x-Cart nos dice en su tutorial que utilicemos su clase PHP llamada templater, la cual está basada en Flexy template engine.

O sea, que primero tengo que aprender a usar esto último antes de comenzar con la clase propia de la tienda x-Cart.

No he encontrado mucha documentación dirigida a principiantes. En este sitio hay un ejemplo BASICO que no logro hacer funcionar.

Si alguien ya tiene experiencia en esto, igual y puede echarme una mano. Mi problema es que no logro hacer una plantilla.

Datos con los que trabajo:
1. Mac OS X 10.8
2. Pear

Bajé el Flexy y trabajo con los siguientes documentos PHP. Cuando ejecuto el primero, no se crea la plantilla y aparece en pantalla: Could not find Template plantilla.html in any of the directories, como si el archivo plantilla.html no se encontrara en la ruta especificada. Y sí, ahí está!

Primer archivo:
Código PHP:
<?php

/* configure the application - probably done elsewhere */
require_once 'flexy/HTML/Template/Flexy.php';
require_once 
'PEAR.php';

$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
$config parse_ini_file('example.ini',TRUE);
$options $config['HTML_Template_Flexy'];


/* the page controller class */

class controller_test 
{

    var 
$template "plantilla.html"// name of template
    
var $title;                  // this relates to {title};
    
var $numbers = array();      // this relates to {numbers} , used with foreach
    
var $anObject;

    var 
$elements = array();      // this is where the elements are stored

    /* start section - deals with posts, get variables etc.*/

    
function controller_test() 
    {
        
$this->start();
        
$this->output();
    }


    function 
start() 
    {
        
// the title
        
$this->title "Hello World";

        
// store an object.
        
$this->anObject = new StdClass;

        
// assign a value to a member.
        
$this->anObject->member 'Object Member';

        
// if you need form elements - you have to include them.
        
require_once 'flexy/HTML/Template/Flexy/Element.php';

        
// create an HTML Element for the form element.
        
$this->elements['input'] = new HTML_Template_Flexy_Element;

        
// assign a value to it
        
$this->elements['input']->setValue('Hello');


        for (
$i 1;$i5;$i++) {
            
$this->numbers[$i] = "Number $i";
        }
    }

    
/* output section - probably best to put this in the default_controller class */

    
function output() {
        
$output = new HTML_Template_Flexy();
        
$output->compile($this->template);
        
$output->outputObject($this,$this->elements);
    }


    function 
someMethod() {
        return 
"<b>Hello From A Method</b>";
    }



}

/* the page controller instantaation - probably done with a factory method in your master page controller class */

new controller_test();

?>

Segundo archivo, llamado ejemplo.html:
Código PHP:
<html>
  <head>
    <title>{title}</title>
  </head>
  <body>
  <H1>{title}</H1>



    <form name="form">
      <table>
        <tr>
          <td>
           <?php /*  this will be merged with the date in the  $element['input']  object*/ ?>
  
            Input Box: <input name="input">
          </td>
        </tr>
  
        <?php /*  note here the use for flexy:foreach as an attribute value */ ?>
  
        <tr flexy:foreach="numbers,number,string">
          <td>
  
        <?php /*   note here the use for flexy:foreach as an attribute value */ ?>
  
            <a href="mypage.html?id=%7Bnumber%7D">{string}</a>
          </td>
        </tr>
      </table>
    </form>




    <?php /*   there is some limited support for array access */ ?>

      this is number 2 : {numbers[2]}


    <?php /*  note that full stops separate object and variables or methods */ ?>

      This is a {anObject.member}

    <?php /* you can call methods of the object */ ?>

      {someMethod()}

    <?php /* by default everything is htmlspecialchar escaped use the modifier :h to prevent this. */ ?>

      {someMethod():h}
    
  </body>
</html>

<?php /*  I've used php for comments here as HTML comments didnt work when generating the
manual .. - you dont have to use them - it has nothing to do with the template engine */ 
?>
Este segundo código está en el archivo plantilla.html (que no sé por qué es HTML si contiene PHP).

El archivo example.ini al que se hace referencia no sé dónde obtenerlo.




Saludos cordiales!


Última edición por berkeleyPunk; 28/03/2014 a las 16:34
  #2 (permalink)  
Antiguo 08/05/2014, 19:47
Avatar de berkeleyPunk  
Fecha de Ingreso: febrero-2013
Ubicación: México :C
Mensajes: 565
Antigüedad: 11 años, 2 meses
Puntos: 22
De acuerdo Respuesta: Cómo hacer plantilla con Flexy template engine?

Para no variar con el subforo de Aplicaciones prefabricadas aquí en Foros del Web, me respondo a mí mismo.

Cuando abrí este post, intentaba trabajar con una plantilla llamada X-Cart, cuya documentación informa que está hecha en base a Flexy template. Como no pude avanzar ni un poco acerca de cómo hacer una plantilla con dicho generador de plantillas, me metí con Prestashop, pero me encontré con el mismo problema, que usa Smarty. Que, al fin y al cabo no supe cómo hacer para armar una plantilla de cero con Smarty.

Me rendí y me puse a editar la plantilla default de Prestashop. Para aparentar una plantilla nueva, que nada tiene que ver con la default de PS, es meterle un montón de CSS, HTML y Javascript al módulo que quiero modificar. Con algo así se logra hacer lo que quiero. Simulación, pero se avanza.

Saludos:

Etiquetas: aplicaciones-prefabricadas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:33.