I have a blade template that includes other blade template. Here is the main template called accountnav.blade.php
@if (count($subaccounts) > 0)
<ul class="nav navbar-nav">
@foreach ($subaccounts as $account)
@include('frontend.template.subaccount', array('p_link' => $account->link))
@endforeach
</ul>
@endif
and here is the included template titled subaccount.blade.php
<li >
@if(count($account->children) == 0 )
<a href=""></a>
@else
<a class="dropdown-toggle" data-toggle="dropdown" href="#" onclick="return false;" aria-expanded="false">
<i class="icon-caret-down"></i>
</a>
@endif
@if (count($account->children) > 0)
<ul class="dropdown-menu">
@foreach($account->children as $account)
@include('frontend.template.subaccount', array('p_link' => $account->link))
@endforeach
</ul>
@endif
</li>
However, when I tried to access the variable p_link
in the subaccount.blade.php
, there is an error that says the variable $p_link is not defined
.
What is the correct way to pass a variable in an @include
and how to access the passed variable?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire