Welcome Guest, Not a member yet? Register   Sign In
My view appears twice
#12

[eluser]Plume[/eluser]
Not sure to understand everything cause bad english.

Have I to route every controller located in sub folder ? What's your content of home.php ?

I tested :
Code:
<?php
class Index extends controller
{
    function index()
    {
        echo 'hey';
    }
}
And I'm obtaining :
Quote:heyhey

When I test :
Code:
<?php
class Index extends Controller{
    
    function index(){
      
      parent::Controller();
      $this->layout->view('home/index');
      echo 'bouh';
    }
}
I'm obtaining :
Code:
bouhbouh
// My view x2

And when I test another url like home/test :
Code:
<?php
class Test extends Controller{
  
  public function test(){
    
    echo 'Hey';
  }
}
I'm obtaining :
Quote:Hey

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Applications/xampp/xamppfiles/htdocs/exotech/system/application/controllers/home/test.php:6)

Filename: errors/error_404.php

Line Number: 1
404 Page Not Found

The page you requested was not found.

I'm lost :/

Layout.php :
Code:
<?php  
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Layout{

  var $obj;
  var $layout;

  function Layout($layout = "layout"){
    
    $this->obj =& get_instance();
    $this->layout = $layout;
  }

  function setLayout($layout){
    
    $this->layout = $layout;
  }

  function view($view, $data=null, $return=false){
    
    $loadedData = array();
    $loadedData['content_for_layout'] = $this->obj->load->view($view,$data,true);

    if($return){
      
      $output = $this->obj->load->view($this->layout, $loadedData, true);
      return $output;
    }else{
      
      $this->obj->load->view($this->layout, $loadedData, false);
    }
  }
}

layout.php ( main layout ) :
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;link rel="stylesheet" type="text/css" href="main.css" /&gt;
  
  &lt;title&gt;Exotech MS&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  <h1>Exotech MS</h1>
  <ul>
    <li><a href="&lt;?php echo ('profile/inscription'); ?&gt;">Inscription</a></li>
  </ul>
  
  &lt;?php echo $content_for_layout; ?&gt;
  
  <div>
     Codé par <a href="mailto:[email protected]">Plume</a>
  </div>
&lt;/body&gt;
&lt;/html&gt;


Messages In This Thread
My view appears twice - by El Forum - 09-29-2008, 02:57 PM
My view appears twice - by El Forum - 09-29-2008, 09:37 PM
My view appears twice - by El Forum - 09-30-2008, 12:27 AM
My view appears twice - by El Forum - 09-30-2008, 03:23 AM
My view appears twice - by El Forum - 09-30-2008, 04:12 AM
My view appears twice - by El Forum - 09-30-2008, 04:19 AM
My view appears twice - by El Forum - 09-30-2008, 04:29 AM
My view appears twice - by El Forum - 09-30-2008, 04:36 AM
My view appears twice - by El Forum - 09-30-2008, 04:43 AM
My view appears twice - by El Forum - 09-30-2008, 04:54 AM
My view appears twice - by El Forum - 09-30-2008, 07:11 AM
My view appears twice - by El Forum - 09-30-2008, 07:25 AM
My view appears twice - by El Forum - 09-30-2008, 07:35 AM
My view appears twice - by El Forum - 09-30-2008, 08:20 AM
My view appears twice - by El Forum - 09-30-2008, 08:28 AM
My view appears twice - by El Forum - 09-30-2008, 08:45 AM
My view appears twice - by El Forum - 09-30-2008, 08:50 AM
My view appears twice - by El Forum - 09-30-2008, 08:56 AM
My view appears twice - by El Forum - 09-30-2008, 09:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB