-
Notifications
You must be signed in to change notification settings - Fork 0
Frontend Templates
Phillip Dornauer edited this page Apr 1, 2026
·
1 revision
Marble resolves URL slugs to Items and renders Blade views from resources/views/marble-pages/. The view filename matches the blueprint identifier.
In routes/web.php:
use Marble\Admin\Facades\Marble;
Marble::routes(function ($item) {
return view(Marble::viewFor($item), ['item' => $item]);
});If you have custom routes (search, login, etc.), define them before Marble::routes() and set MARBLE_AUTO_ROUTING=false in .env.
For blueprint identifier blog_post, Marble looks for:
resources/views/marble-pages/blog_post.blade.phpresources/views/marble-pages/default.blade.php- Package built-in fallback
@extends('layouts.frontend')
@section('title', $item->name())
@section('content')
<h1>{{ $item->name() }}</h1>
{!! $item->value('content') !!}
@endsection{{ $item->value('title') }} {{-- Current language --}}
{!! $item->value('content') !!} {{-- HTML — avoid escaping --}}
{!! nl2br(e($item->value('summary'))) !!} {{-- Preserve line breaks --}}
{{ $item->value('title', 'de') }} {{-- Specific language --}}@php $nav = Marble::navigation(); @endphp
@foreach($nav as $navItem)
<a href="{{ Marble::url($navItem) }}">{{ $navItem->name() }}</a>
@foreach($navItem->navChildren as $child)
<a href="{{ Marble::url($child) }}">{{ $child->name() }}</a>
@endforeach
@endforeach@php $crumbs = Marble::breadcrumb($item); @endphp
@foreach($crumbs as $crumb)
@if(!$loop->last)
<a href="{{ Marble::url($crumb) }}">{{ $crumb->name() }}</a> /
@else
{{ $crumb->name() }}
@endif
@endforeach@foreach(Marble::children($item, 'blog_post') as $post)
<a href="{{ Marble::url($post) }}">{{ $post->name() }}</a>
@endforeach@php
$posts = Marble::items('blog_post')
->published()
->orderBy('created_at', 'desc')
->paginate(10);
@endphp
@foreach($posts as $post)
<h2><a href="{{ Marble::url($post) }}">{{ $post->name() }}</a></h2>
@endforeach
{{ $posts->links() }}@php $img = $item->value('hero_image'); @endphp
@if($img)
<img src="{{ $img->url(1200, 600) }}" alt="{{ $item->name() }}">
@endif@php $author = $item->value('author'); @endphp
@if($author instanceof \Marble\Admin\Models\Item)
By <a href="{{ Marble::url($author) }}">{{ $author->name() }}</a>
@endif@foreach($item->value('features') as $feature)
<h3>{{ $feature['title'] ?? '' }}</h3>
<p>{{ $feature['description'] ?? '' }}</p>
@endforeach{{ Marble::settings()?->value('site_name') }}@if(Marble::isPortalAuthenticated())
Welcome, {{ Marble::portalUser()?->email }}
<form action="{{ route('marble.portal.logout') }}" method="POST">
@csrf <button type="submit">Sign out</button>
</form>
@else
<a href="{{ route('marble.portal.login') }}">Sign in</a>
@endif<x-marble::marble-form :item="$item">
<button type="submit">Send</button>
</x-marble::marble-form>Set MARBLE_DEBUGBAR=true in .env. A floating debug panel appears on the frontend when an admin is logged in, showing item info, field values, and cache state.