Blade: how to include a section in one page but not in another
Ad
I have a report that I present on screen.
report.blade.php
<html>
<head>
</head>
<body>
@yield('content')
</body>
</html>
report_sub1.blade.php
@extends('reports.report')
@section('content')
<h1> This is sub section 1 </h1>
<h1> This is sub section 2 </h1>
@stop
I want to include the section 2 in the 1st report but not in the second. Meaning I have two identical reports, but the one should not print section 2.
How can you do that?
Ad
Answer
Ad
You could use your report.blade.php
as a master page. Then use two partials as sub-sections, and use a third partial for section 1
. Finally include this last partial only where you need it:
section1.php
<!-- section 1 definition-->
<h1> This is sub section 1 </h1>
report_sub1.blade.php
@extends('reports.report')
@section('content')
<!-- section 1 included -->
@include('section1')
<!-- section 2 included only here-->
<h1> This is sub section 2 </h1>
@stop
report_sub2.blade.php
@extends('reports.report')
@section('content')
<!-- section 1 included -->
@include('section1')
<!-- section 2 included is not included here-->
@stop
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad