【发布时间】:2017-06-17 01:52:45
【问题描述】:
我的数据库中有一个名为网站的表。
里面有两个字段:
name = 值为“name” html =(存储在该字段中的整个 html 代码)
所以目前我想做的是:
如果我在浏览器中键入 localhost/website/name 这是数据库中的变量,并且在我按下回车键后,我想从与该名称关联的字段 html 中显示实际呈现的 html 页面,因此它看起来像这样:
<!DOCTYPE html>
<html>
<head>
<title>Template 1</title>
<link href="http://localhost/templates/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="logo">
<img class="images" id="image" src="#" alt="Your Logo"/>
</div>
<div contenteditable="true" id="content" class="draggable ui-widget-content refresh"><p>Change Text inside this box</p></div>
<div id ="editTxt" class="refresh" contenteditable="true">
<p>This text can be by the user.</p>
</div>
</body>
</html>
显然我不想看到代码,而是看到实际页面。怎么可能?
website.blade.php:
@extends('layouts.master') @section('title', 'Website Builder') @section('content')
<meta name="csrf-token" content="{{ csrf_token() }}" />
{{html_entity_decode($website->html)}}
</html>
@endsection @show
路线:
Route::get('website/{name}', 'BuilderController@websites');
控制器:
function websites($name)
{
$websites = Website::find($name);
return view('layouts/website');
}
以及当前的错误信息(假设如果这个错误得到修复,这段代码将显示页面)
未定义变量:网站(查看: C:\xampp\htdocs\fyproject\resources\views\layouts\website.blade.php)
所以基本上 value 'name' => 'null' 而在我的数据库中却不是这样,为什么会发生这种情况?
【问题讨论】:
标签: laravel