I have an #include problem with my bootstrap navbar. I worked on it this morning and I really don't know where the problem is.
Here is the error message :
View [layouts.navbar] not found.
I want to include the content of navbar.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Mana Tournaments</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
{!! Html::style('css/style.css') !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css') !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css') !!}
</head>
<body>
<div class="container">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Logo</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Accueil</li>
<li>Tournois</li>
<li>Inscription</li>
<li>Contact</li>
</ul>
</div>
</nav>
</div>
</body>
</html>
To my index page (welcome.blade.php)
<!DOCTYPE html>
<html>
<head>
<title>Mana Tournaments</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
{!! Html::style('css/style.css') !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css') !!}
{!! Html::style ('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css') !!}
</head>
<body>
<h1>Gestionnaire de tournois</h1>
<div class="container">
#include('layouts.navbar')
</div>
</body>
</html>
I created manually a layout folder, then i created the navbar file. If I did someting wrong, maybe there's a command line for laravel for creating a folder ?
Thank you for helping me on my problem.
First of all,
Make sure the view you're including exists in the correct folder.
#include('layouts.navbar') will include that path \resources\views\layouts\navbar.blade.php
Make sure, The file within layouts directory,
Second, You don't need to write the whole html for the included part.
navbar.blade.php will be added (included) to welcome.blade.php,
it's like you're copying the content of navbar.blade.php and adding it to welcome.blade.php,
So make it like this instead,
navbar.blade.php
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Logo</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Accueil</li>
<li>Tournois</li>
<li>Inscription</li>
<li>Contact</li>
</ul>
</div>
</nav>
That's because that file is not in the app/views directory. When you call #include('filename'), Blade automatically looks for any file with that name, inside the apps/views directory. Also, you're not supposed to write the file extension, as Blade automatically looks for files with .blade.php and .php extensions.
For Laravel 5 use this folder
resources/views/
Related
#extends , #section and #yield work for the main welcome page, but I made a new product-gel.blade.php file in view and used the #extends and #section and #endsection on it but it doesnt seem to work.
Here is the yield place
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="..\resources\stylecss\style.css">
#vite(['resources/css/app.css', 'resources/js/app.js'])
<script></script>
</head>
<body>
<div id="app">
<section id="header">
<div class="main-pages-box">
<div class="main-pages">
CUSTOMER CARE
#if (Route::has('login'))
#auth
<a> {{Auth::user()->name}} </a>
LOG OUT
#else
LOGIN
#if (Route::has('register'))
REGISTER
#endif
#endauth
#endif
</div>
</div>
<div class="main-bar">
<div class="daraz-logo-container">
<img src="../resources/images/daraz_logo.png" alt="daraz_logo" class="daraz-logo">
</div>
<div class="search-box-container">
<form onSubmit="searching();">
<input type="text" placeholder=" Search on Daraz" name="search" class="search-bar" id="text-to-search">
<a onclick="searching();" class="search-btn"></a>
<img src="../resources/images/cart-icon.png" alt="">
<img src="../resources/images/downloadnow-icon.png" alt="">
</form>
</div>
</div>
</section>
<script src="../resources/scriptfiles/searching.js"></script>
#yield('content')
<section id="footer">
<div class="customer-care-end">
<h1>Customer Care</h1>
<ul>
<li>Help Center</li>
<li>How to Buy</li>
<li>Corporate & Bulk Purchasing</li>
<li>Returns & Refunds</li>
<li>Daraz Shop</li>
<li>Contact Us</li>
<li>Purchase Protection</li>
<li>Daraz Pick up Points</li>
<li>Fulfulled By Daraz (FBD)</li>
</ul>
</div>
<div class="codenthx">
<div class="QRcode"></div>
<div class="appdl">
<div class="QRthx"></div>
<p>Happy Shopping</p>
</div>
</div>
</section>
</div>
</body>
</html>
And here is the new file im trying to extend on (removed the html file and just put it a header testing file to see if it works)
#extends('layouts.frontend')
#section('content')
<div>
<h1>testing</h1>
</div>
#endsection
This works on the welcome.blade.php file but not on the product-gel.blade.php file.
this is what the directory is looking like for the welcome page
view > welcome.blade.php
and for the product one
view > produ > product-gel.blade.php
I have also tried moving the gel.blade.php file outside of produ folder like this
view > product-gel.blade.php
But that also doesnt work, I am still new to laravel so dont know what I am doing wrong here.
https://imgur.com/a/2crydOm
This is what it looks like.
My navbar in one of my laravel (php framework) project suddenly stopped working, I think I've tried everything with it but nothing works nor get me back to the point where it was working, any solutions or suggestions how to fix this issue?
navbar
<div class="container mx-auto flex justify-between p-4">
<h1 class="text-xl font-black">stackoverflow</h1>
<nav class="navbar navbar-inverse navbar-fixed-top">
Home
About
</nav>
</div>
web.php
Route::get('/', function () {
return view('index');
})->name('home');
Route::get('/about', function () {
return view('about');
})->name('about');
default
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>sss</title>
<link rel="stylesheet" href="{{ asset('css/app.css')}}">
</head>
<body class='bg-sky-500 text-white'>
<header class="fixed bg-sky-400 top-0 left-0 right-0" z-50>
<div class="container mx-auto flex justify-between p-4">
<h1 class="text-xl font-black">ssss</h1>
<nav class="navbar navbar-inverse navbar-fixed-top">
Home
About
</nav>
</div>
</header>
<main>
#yield('page-content')
</main>
<footer>
<div class="container mx-auto p4">
<p>©
<a>ssss</a>
sss
ssss
</p>
</div>
</footer>
</body>
</html>
EDIT:
https://github.com/wsamselbaudat/LaravelProject
resources/views/
2 blade.php files(ignore dashborad), on the about page the navbar is working perfectly fine, I want the navbar to be working on index.blade.php
You can check for current url using the request() helper is() method
or can get the current url using request()->url() method and compare it with the link route url
Try this
Home
Home
Or
Home
Home
Hi I am trying to show side bar images which is in PHP from Include folder into PHP page but images are not showing on my page.
sidebar.php is used in other php files too which are present in root directory and for root directory files side.php images are working fine, only it gives me error in root-->folder-->newfile.php (here i include my side bar.php)
Root Directory --
include folder ---> sidebar.php
img --->me1.png
unesco-weltkulturerbe-suedafrika-reisen folder ---> abc.php
Sidebar.php
<div class="container-fluid">
<div class="row">
<nav class="social">
<ul>
<li><img src="img/me1.png" width="18">Tell: 02241-9424211 </li>
<li><img src="img/me2.png" width="18">Fax: 02241-9424299 </li>
<li><img src="img/me3.png" width="18">afrika#bct-touristik.com </li>
<li><img src="img/me4.png" width="18">Kurze Mitteilung o. Rückruf</li>
<li><img src="img/me5.png" width="18">Katalogbestellung</li>
<li><img src="img/me6.png" width="18">Reiseanmeldung</li>
<li><img src="img/me7.png" width="18">Übersicht alle Reisen</li>
</ul>
<div class="clearfix"></div>
</nav>
</div>
</div>
abc.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- Side menu widget -->
<?php include('includes/sidebar.php'); ?>
<!-- Header includes menu too -->
<?php include('includes/header.php'); ?>
<div class="container-fluid about-inner">
<div class="row">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>Das Weltkulturerbe und Weltnaturerbe in Südafrika</h2>
<ul class="breadcrumb">
<li>Home</li>
<li>Das Weltkulturerbe und Weltnaturerbe in Südafrika</li>
</ul>
</div>
</div>
</div>
</div>
</div>
You are displaying all images in the form
img/me1.png
img/me2.png
img/me3.png
img/me4.png
img/me5.png
img/me6.png
This will not work at all because img is a subfolder and images are not in root directory. Use this form instead:
/img/me1.png
/img/me2.png
/img/me3.png
/img/me4.png
/img/me5.png
/img/me6.png
The images should load now.
I'm using laravel-breadcrumbs package by diglactic with laravel 8 forked from davejamesmiller/laravel-breadcrumbs I'm trying to add dynamic page title based on this breadcrumbs package.
what I mean by dynamic page title ? let's imagine that every page I have it contain a page title section like this :
HTML: (Every Page it have this section below the navbar)
<section class="py-5 text-center container">
<div class="row py-lg-5">
<div class="col-lg-6 col-md-8 mx-auto">
<h1 class="fw-bold mb-4">Page Title Here</h1> // Dynamic Page Title Here
</div>
</div>
</section>
You can make your own breadcrumb. First you should generate blade component something like php artisan make:component breadcrumb and then look at the code, I use it anyway and it success
AppServiceProvider.php
public function boot()
{
// your prev code
view()->share('currentPath', explode('/', substr_replace(request()->path(), '', 0, 3)));
}
componenents/breadcrumb.blade.php
<nav>
<ul class="breadcrumbs">
<li class="breadcrumb-item pl-0">
Home
</li>
#foreach ($paths as $path)
<li class="breadcrumb-item pl-0 text-capitalize
{{ $loop->last ? 'active' : '' }}">
<a href="{{ url($path) }}">
{{ str_replace('-', ' ', $path) }}
</a>
</li>
#endforeach
</ul>
</nav>
And use it in any view like this
<x-breadcrumb :paths="$currentPath" />
You can use #yield to cahnge a section of your template dynamically.
check the documentation for more info.
The #yield is use to dynamic title
here i am create a template.blade.php file and title.blade.php.
the title.blade.php is extends template.blade.php file and title can dynamic is work perfectly.
template.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#yield('title')</title>
</head>
<body>
The title is dynamically
</body>
</html>
title.blade.php
#extends('template')
#section('title')
My Title
#endsection
Laravel view page displays additional '<' character,but it is not given in the code. How can I fix it? I have given the blade.php code for the view. While inspecting, all the tags are misplaced and the head tag is shown inside the body tag.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
</head>
<body>
<div class="flex-center position-ref full-height">
#if (Route::has('login'))
<div class="top-right links">
#auth
Home
#else
Login
#if (Route::has('register'))
Register
#endif
#endauth
</div>
#endif
<div class="content">
<div class="title m-b-md">
Laravel
</div>
<div class="links">
Docs
Laracasts
News
Blog
Nova
Forge
GitHub
</div>
</div>
</div>
</body>
</html>