Reputation: 177
I'm trying to add a funtionality to a web app where I need the current page header as a variable. Could you please tell me how to process the page below in server before serving and assign the the text inside HTML tag h2
to a php variable '($currentPageHeader)'? Thank you
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<!-- Styles -->
<style>
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
<h2>Text to be extracted</h2>
</div>
<div class="links">
</div>
</div>
</div>
<?php $currentPageHeader = "Text to be extracted"; ?> // Content of <h2>
</body>
</html>
Upvotes: 0
Views: 1376
Reputation: 12391
create master.blade.php
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<!-- Styles -->
<style>
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="content">
<div class="title m-b-md">
@yield('content')
</div>
<div class="links">
</div>
</div>
</div>
</body>
</html>
then you can extend that
@extends('master')
@section('content')
<p>This is my body content.</p>
@stop
ref link https://laravel.com/docs/5.0/templates#blade-templating
Upvotes: 1