Question

I just did a fresh install of laravel 4.1. I am not really a big fan of templating languages so I would just prefer to use regular php for the templating. However, I do like the idea of inheritance and sections that laravel provides. I have seen examples of using the sections like so:

<?php Section::start('content'); ?>
    Test Content
<?php Section::stop(); ?>

However, when I try this on my install I am getting:

Class 'Section' not found

When I try doing it with the blade templates it works fine but not with a regular php template. I cannot find any documentation at all about just regular php templates, all I can find is documentation on blade. Is this not available in the new version or has it changed? Any links or help would be greatly appreciated as googling keeps coming up with results for how to use blade templates.

Was it helpful?

Solution

You are looking for View actually Illuminate/View/Environment.php:

<!-- layuts/mastrer.php -->

<body>
    <?php echo View::yieldContent('content'); ?>
</body>

<!-- views/home/index.php -->

<?php View::startSection('content'); ?>

    <?php echo 'Welcome ' . $name; ?>

<?php View::stopSection(); ?>

BaseController class:

protected $layout = 'layouts.master';

protected function setupLayout()
{
    if ( ! is_null($this->layout))
    {
        $this->layout = View::make($this->layout);
    }
}

HomeController class:

public function ShowHome()
    $this->layout->title = 'Laravel -> Lout';
    $this->layout->content = View::make('home.index', ['name' => 'Sheikh Heera']);
}

But, if you use these functions then why not just use the blade ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top