Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/06/2011, 21:22
edlopezmax2010
 
Fecha de Ingreso: junio-2011
Ubicación: Medellín-Colombia
Mensajes: 7
Antigüedad: 12 años, 10 meses
Puntos: 0
Exclamación Problema con Master Pages!!

Hola que más!! Soy un estudiante y estoy aprendiendo PHP tengo un problemita.
Tengo una Master Page, Bueno quiero que cuando le de click en un boton la página que está contenida cambie... por otra...

Mi código es el Siguiente:

Pagina Master:
Código HTML:
<html>
    <head>
        <title>Prueba!!</title>
    </head>
    <body>

        <table width="20%" align="right" border="5%">
            <td width="20%" height="100%">
                    [PHP]  <?Php
                          include("Plantilla.php");
                         $Contenido=new Plantilla("P1");
                         $Contenido->asigna_variables(array("variable" => "P1"));
                         $ContenidoString = $Contenido->muestra();
                        echo $ContenidoString;
                    ?>[/PHP]
            </td>
        </table>

        <input type="button" name="P2" value="P2">

  </body>
</html> 

Quieroo que mi boton me cambié la página que está contenida ( P1)!! Por otra (P2)

P1:
Código HTML:
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>P1</title>
    </head>
    <body>
        <h3 align="center">Estamos en P1</h3>
    </body>
</html> 
P2:

Código HTML:
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>P2</title>
    </head>
    <body>
        <h3 align="center">Estamos en p2</h3>
    </body>
</html> 
Yo había pensado en algo como ésto para probar con un select:
Utilizando el <Form></Form>

<form action="Contenidas.php" method="post">
<table border="5%">
<td>
Página:<select name="CbPagina">
<option>1</option>
<option>2</option>
<option>3</option>
</select><br/>
<input type="submit" name="submit">
</td>
</table>
</form>

Contenidas.php
Código PHP:
<?php
    
include("Plantilla.php");

$Pagina=$_POST["CbPagina"];

       
            if(
$Pagina==1){
                echo 
1;
                
Configurar_Plantilla("P1");//Página 1
            
}
            else if(
$Pagina==2){
                echo 
2;
                
Configurar_Plantilla("P2");//Página 2
            
}
            else if (
$Pagina==3){
                 echo 
3;
                
Configurar_Plantilla("P3");//Página 3
            
}
        

        function 
Configurar_Plantilla($P) {
            
$Contenido=new Plantilla($P);
            
$Contenido->asigna_variables(array("variable" => $P));
            
$ContenidoString $Contenido->muestra();
            echo 
$ContenidoString;
             
//header("Location: HolaMundo.php");
         
}
?>

Por último esta es mi clase Plantilla:
Código PHP:

<?
class plantilla{
        function 
plantilla($template_file){
                
$this->tpl_file $template_file.'.php';
        }

        function 
asigna_variables($vars){
                
$this->vars= (empty($this->vars)) ? $vars $this->vars $vars;

        }

        function 
muestra(){
                if (!(
$this->fd = @fopen($this->tpl_file'r'))) {
                        
sostenedor_error('error al abrir la plantilla ' $this->tpl_file);
                } else{
                        
$this->template_file fread($this->fdfilesize($this->tpl_file));
                        
fclose($this->fd);
                        
$this->mihtml $this->template_file;
                        
$this->mihtml str_replace ("'""\'"$this->mihtml);
                        
$this->mihtml preg_replace('#\{([a-z0-9\-_]*?)\}#is'"' . $\\1 . '"$this->mihtml);
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                $
$key $val;
                        }
                        eval(
"\$this->mihtml = '$this->mihtml';");
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                unset($
$key);
                        }
                        
$this->mihtml=str_replace ("\'""'"$this->mihtml);
                        echo 
$this->mihtml;
                }
        }
}

?>
Muchas Gracias