Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:59:30+00:00 2026-06-14T19:59:30+00:00

I googled two hours, but not found answer. Maybe you can help. When I

  • 0

I googled two hours, but not found answer. Maybe you can help.

When I define in MyController:

class MyController extends Base_Controller {
    public $layout = 'layouts.default';

    public function get_index() {
        $entries = Entry::all();
        return View::make('entries.index')
            ->with('entries', $entries);
        }
    }
}

In entries\index.blade.php:

@section('content')
    <h1>Test</h1>
@endsection

And in layouts\default.blade.php:

<!DOCTYPE html>
<html>
<body>
    @yield('content')
</body>
</html>

Nothing is displaying. And I don’t understand why. When I am replacing in MyController return part with:

$this->layout->nest('content', 'entries.index', array(
    'entries' => $entries
));

Then all is working, but.. It looks not clean and I don’t like it. When adding in every view @layout('layouts.default') all is working good too, but it is not DRY. For example, in RoR I don’t need to do such things in Controller.

How can define in MyController one layout and use return View::make (I think that this is right way) or how can do it better?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:59:31+00:00Added an answer on June 14, 2026 at 7:59 pm

    To use layouts in controllers, you must specify:

    public $layout = 'layouts.default';
    

    You can also not return in the method as it will override the use of $layout. Instead, to embed your content within the layout you use:

    $this->layout->nest('content', 'entries.index', array('entries' => $entries));
    

    No need to return anything in your method now. This will fix it.


    Edit:

    “Beautiful Ways?”

    $this->layout->nest('content', 'entries.index')->with('entries', $entries);
    
    
    $this->layout->content = View::make('entries.index')->with('entries', $entries);
    
    
    $this->layout->entries = $entries;
    $this->layout->nest('content', 'entries.index');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm terribly new to Hibernate. I've googled for two hours but I still can't
I've spent my requisite two hours Googling this, and I can not find any
I've searched Google for hours, but I can't find the answer anywhere. I have
I searched for two hours but only found draw Line, i want get direction
Possible Duplicate: Why are two different concepts both called “heap”? I've googled around, but
I've been trying to solve these problem for last two hours but seems like
Possible Duplicate: Problem with database in CodeIgniter Alright, I've googled this the last two
I have two data sets in google app engine datastore. class First_Set(db.Model): start_time =
I've spent two days on this and I still can't find the cause of
I have been roaming in google with this for couple of hours now. Two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.