Laravel PHP, navbar "not active" - php

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

Related

#extends and #yield in laravel not working for second blade file

#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.

Path is correct but images are not showing?

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.

Laravel View contains additional '<' character

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>

Laravel - Using of yields / extends

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/

php unable to use bootstrap when include() is used

I've below HTML code which I intend to use with index.php file but there seems a problem.
<!-- nav bar -->
<nav id="top">
<nav class="navbar navbar-xs navbar-custom">
<div class="container-fluid" >
<div class="nav pull-right">
<font face="bebas">
<ul class="list-inline">
<li> 123456789 </li>
<li class="dropdown"><i class="fa fa-user"></i> My Account <span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-right">
<li>Register</li>
<li>Login</li>
</ul>
</li>
<li><i class="fa fa-heart"></i> Wish List (0)</li>
<li><i class="fa fa-shopping-cart"></i> Shopping Cart</li>
<li><i class="fa fa-share"></i> Checkout</li>
</ul>
</div>
</div>
</nav>
</nav>
<!-- searchbar and logo -->
<header id="margin">
<div class="container">
<div class="row">
<div class="col-xs-4">
<div id="logo">
<center> <span class="tab-space"></span> <img src="J:\lawn\home\artwork\lawn.png" height="42px" />
</div>
</div>
<div class="col-xs-5">
<div id="search" class="input-group">
<input type="text" name="search" value="" placeholder="Search" class="form-control" border-rad>
<span class="input-group-btn">
<button class="btn btn-secondary" type="button" style="border-radius: 0;">Search</button>
</span>
</div>
</div>
<div class="col-xs-3">
</div>
</div>
</div>
</font>
</header>
index.php
<!DOCTYPE html>
<html>
<head>
<title> experiment ground </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- <meta name="viewport" content="width=device=width, initial-scale=1"> omitted to remove unresponsiveness of columns -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="J:\bootstrap\bootstrap-3.3.6-dist\css\bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="J:\bootstrap\bootstrap-3.3.6-dist\css\cutom.css" rel="stylesheet" type="text/css">
<script src="J:\bootstrap\bootstrap-3.3.6-dist\js\bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<?php include('includes\header.html'); ?>
</body>
</html>
i want an output like this but all i am getting is this.
is it a problem with using bootstrap or something else entirely.
my main purpose is to use include() feature of PHP to make my code minimal. is there any other way I can include headers or footers templates or codes to a PHP page?
thank you!
Link jQuery before you include Bootstrap
<link href="J:\bootstrap\bootstrap-3.3.6-dist\css\bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="J:\bootstrap\bootstrap-3.3.6-dist\css\cutom.css" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"</script>
<script src="J:\bootstrap\bootstrap-3.3.6-dist\js\bootstrap.min.js"></script>
1) open your Developer Tools (F12)
2) refresh page
3) check "console" tab
I think, you'll find answers in console.
Anyway, change your paths to relative (assuming file index.php at one tree level with bootstrap directory):
href="bootstrap\bootstrap-3.3.6-dist\css\bootstrap.min.css"
Instead of:
href="J:\bootstrap\bootstrap-3.3.6-dist\css\bootstrap.min.css"
And do it for all files, or just connect it from CDN - it will be great ;)
Call jquery.min.js before bootstrap.min.js
The script bootstrap.min.js uses jQuery plug-in in most actions.
Also, check if the files are actually in the path described. It is highly recommended that you call the files from the main project directory.

Categories