如何通过从后端数据列表中获取数据来在laravel上制作动态标题
guest.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="Yucel Yilmaz">
<meta name="robots" content="index,follow">
<meta name="publisher" content="Yücel Yilmaz">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title') | ecommerece</title>
</head>
<body>
</body>
</html>
cities-page-component.blade.php
<div>
@section('title', 'Laundry Near Me')
</div>
listing-page-component.blade.php
<div>
@section('title', 'Laundry Near Me')
</div>
如何通过laravel中的后端数据在产品详细信息页面中使标题动态,
就像我有一个城市列表,在城市里有很多洗衣店。 在主页上,我们可以搜索城市,以便从数据库中显示城市列表。当用户点击任何城市时,页面将被定向到另一个包含洗衣店列表的页面所以我希望标题为{{城市名称}}
中的洗衣店 同样,当用户点击任何洗衣店时,页面将定向到洗衣店的详细信息页面,因此我希望标题为 {{ 洗衣店名称 }}
in {{ city name }}
guest.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="Yucel Yilmaz">
<meta name="robots" content="index,follow">
<meta name="publisher" content="Yücel Yilmaz">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title') | ecommerece</title>
</head>
<body>
</body>
</html>
cities-page-component.blade.php
<div>
@section('title', 'Laundry Near Me')
</div>
listing-page-component.blade.php
<div>
@section('title', 'Laundry Near Me')
</div>
how do I make Title dynamic in the product detail page from the data from the backend in laravel
like an I have a list of cities, under the cities, there is a bunch of laundries.
On the main page, we can search for cities so the list of cities is shown from the database. when the user clicks any of the cities the page will be directed to another page with a list of laundries so I want the title to be laundries in {{ city name }}
same way when the user clicks on any laundry the page is directed detail page of laundries so the title I want to be {{ laundry name }}
in {{ city name }}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过模板继承为标题设置
@yield
。布局
视图中的
集
$dynamicTitle
:您可以使用$dynamicTitle
或为
例如。取决于您的需求。@section('title')
自由分配值>$item->titleYou can set
@yield
for title via template inheritance.Layout
Set
$dynamicTitle
in view :You are free to assign a value to the
@section('title')
using$dynamicTitle
or$item->title
for example. Depends on your needs.您可以在返回城市记录时将城市标题存储为城市选择控制器中的会话变量
,并在洗衣房视图中使用它,
同样在返回洗衣记录时将洗衣房标题保存为
并在详细视图中使用它,例如
You can store the City Title as session variable in cities selection controller when returning city record with
and use it in your laundries view as
likewise save laundry Title when returning laundry record as
and use it in your detail view like