Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
new user, fresh install, need help
  • hi, I have altered the welcome controller to split up the view into a layout with header and content vars. Mod the controller action_index:
    public function action_index()
     {
    
         $view = View::factory('layout');
         
         $view->head = View::factory('header');
         $view->content = View::factory('welcome/index');
     
         $this->output = $view;
    
     }
    
    Now the browser output is blank with no errors and no source code. What am i doing wrong?
  • Hi, Presuming layout exists in views are you echoing $head and $content in your view?
    <?php echo $head; ?>
    <?php echo $content; ?>
    

    Phil.
  • hi this is my layout code: <html>
    <head>
    <?php echo $head; ?>
    </head>
    <body>
    <?php echo $content; ?>
    </body>
    </html>
  • hi, create a new controller called Controller_Test (under app/controllers/test.php) as such:
    class Controller_Test extends Controller_Template {
         
         // This will make your template file views/template/someview.php
         public $template = 'template/someview';
         
        public function action_index()
        {
              // File under views/partials/header.php
              $this->template->header = View::factory('partials/header');
              $this->template->footer = 'this is a footer string, could also be a view file';
        }
    }
    

    create a view called someview.php and put it under views/template/someview.php
    <html>
    <head>
         <title>My first template</title>
    </head>
    <body>
         <h1>welcome</h1>
        <div class="header">
            <?=$header?>
        </div>
       <div class="main">
           if you assigned a $main variable in your controller (i.e. $this->template->main = 'something' you could echo $main here. there is no limit to how many template properties you have you could have $this->template->roflmao_nerdburger = 'haha' in your view and just echo $roflmao_nerdburger here.
       </div>
       <div class="footer">
           <?=$footer?>
        </div>
    </body>
    </html>
    

    hope this gets you started. see here for more.
  • Using the template controller is one way. The problem with you current function is that it still uses $this->output which was removed for RC1 in favor of a response object. Now you change it like this:
    public function action_index()
     {
    
         $view = View::factory('layout');
         
         $view->head = View::factory('header');
         $view->content = View::factory('welcome/index');
     
         $this->response->body = $view;
    
     }
    

    Let us know if the manual still refers to $this->output somewhere, I thought we had gotten rid of those.
  • HI, Thanks for you suggestion, i will try tomorrow at work. Yep, manual still ref $this->output. http://fuelphp.com/docs/general/views.html Cheers,
    Trav.
  • yep this worked. $this->response->body = $view
  • oh whoops fully didn't even notice the $this->output!
  • Don't worry Ben neither did I :-D Phil.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion