2

I'm having difficulty getting my head around laravels blade templates.

I have a master.blade and I have an index.blade, no problems there.

What I want to do is inside my index.blade I want to nest another view: modal.blade

    // modal.blade.php
     <!-- Modal -->
    <div id="message" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">{{ $header }}</h3>
        </div>
        <div class="modal-body" style="min-height: 430px">
            {{ $modal_content }}
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            {{ Form::submit('Save', array('class' => 'btn btn-primary')) }}
        </div>
    </div>

And I want to dynamically generate content for my modal.blade depending on the value of some variable inside my index.blade. Have I completely got the wrong idea or can this be done? Could someone please point me in the right direction? Any help greatly appreciated.

user1543871
  • 355
  • 1
  • 6
  • 16

2 Answers2

4

Try this:

@include(view.name);
cch
  • 3,336
  • 8
  • 33
  • 61
Skid Kadda
  • 482
  • 3
  • 14
  • also try https://stackoverflow.com/questions/21753954/how-to-include-a-sub-view-in-blade-templates/21755728#21755728 – GWed Nov 15 '17 at 16:07
2

Basically you will need to @include('your.modal'), but there are some answers that may clarify layouting even better to you here: Templating in Laravel.

Community
  • 1
  • 1
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204