Display pages of a book or content of a single page on default.blade.php #3971

Closed
opened 2026-02-05 07:59:32 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @Man-in-Black on GitHub (Aug 15, 2023).

Describe the feature you'd like

I would like to display the content, e.g. from a "news" page directly on the default.blade.php so that I can update the page without editing the visual theme.
I don't want to change the start page in this case.
Or maybe to show the last 5 Pages from a specific book.
At the moment I have the following solution with a link to the news book:
image
I also made some changes with the visual theme system to the default.blade.php
But it would be much nicer if the last 5 pages of a single can be displayed in a card.

Describe the benefits this would bring to existing BookStack users

Show recent news from a "news" book to all users.

Can the goal of this request already be achieved via other means?

I didn't find an option for this.

Have you searched for an existing open/closed issue?

  • I have searched for existing issues and none cover my fundemental request

How long have you been using BookStack?

0 to 6 months

Additional context

No response

Originally created by @Man-in-Black on GitHub (Aug 15, 2023). ### Describe the feature you'd like I would like to display the content, e.g. from a "news" page directly on the default.blade.php so that I can update the page without editing the visual theme. I don't want to change the start page in this case. Or maybe to show the last 5 Pages from a specific book. At the moment I have the following solution with a link to the news book: ![image](https://github.com/BookStackApp/BookStack/assets/9048534/4823ff36-3dd4-4cd9-9630-c4174e5b336a) _I also made some changes with the visual theme system to the default.blade.php_ But it would be much nicer if the last 5 pages of a single can be displayed in a card. ### Describe the benefits this would bring to existing BookStack users Show recent news from a "news" book to all users. ### Can the goal of this request already be achieved via other means? I didn't find an option for this. ### Have you searched for an existing open/closed issue? - [X] I have searched for existing issues and none cover my fundemental request ### How long have you been using BookStack? 0 to 6 months ### Additional context _No response_
OVERLORD added the 🔨 Feature Request label 2026-02-05 07:59:32 +03:00
Author
Owner

@Man-in-Black commented on GitHub (Aug 26, 2023):

I just changed the title and the description a bit after some adjustment on my installation.
I also set tags for the news pages.

@Man-in-Black commented on GitHub (Aug 26, 2023): I just changed the title and the description a bit after some adjustment on my installation. I also set tags for the news pages.
Author
Owner

@ssddanbrown commented on GitHub (Aug 29, 2023):

Thanks for the request @Man-in-Black, but to be honest this kind of specific desire is exactly what the visual theme system is intended for, since I don't want the main platform to get dug into the depths of feature variation and customization options & controls.

If you need some guidance getting what you desire with such a customization (For example, writing a query for something you specifically want to list) feel free to ask though.

@ssddanbrown commented on GitHub (Aug 29, 2023): Thanks for the request @Man-in-Black, but to be honest this kind of specific desire is exactly what the visual theme system is intended for, since I don't want the main platform to get dug into the depths of feature variation and customization options & controls. If you need some guidance getting what you desire with such a customization (For example, writing a query for something you specifically want to list) feel free to ask though.
Author
Owner

@Man-in-Black commented on GitHub (Aug 29, 2023):

I understand your approach and I almost thought so too, so I've been working on it further, but haven't found a final solution yet.

I would be very happy about a little support.

My intended goal is the following:
I have a book in which I maintain the pages with the news.
Now I would like to see only the 5 most recent news pages displayed in this tile on the default page.
I've already started to create a function.php that only shows me the pages of this book, but I don't know how I can display this as a link in default.blade.php.

function.php:

<?php

use BookStack\Entities\Models\Page;
use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;
use Illuminate\Support\Facades\Route;

function getnews() {
     Theme::listen(ThemeEvents::APP_BOOT, function () {
         Route::get('/news', function () {
             $news = Page::query()->where('book_id','95')->pluck('name')->join("\n");
             // return view('home.news', $news)
             return response($news, 200, ['Content-Type' => 'text/plain']);
         });
     });
}

getnews();

Maybe there is an easier way to display the pages.
Thank you in advance.

@Man-in-Black commented on GitHub (Aug 29, 2023): I understand your approach and I almost thought so too, so I've been working on it further, but haven't found a final solution yet. I would be very happy about a little support. My intended goal is the following: I have a book in which I maintain the pages with the news. Now I would like to see only the 5 most recent news pages displayed in this tile on the default page. I've already started to create a function.php that only shows me the pages of this book, but I don't know how I can display this as a link in default.blade.php. function.php: ~~~ <?php use BookStack\Entities\Models\Page; use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; use Illuminate\Support\Facades\Route; function getnews() { Theme::listen(ThemeEvents::APP_BOOT, function () { Route::get('/news', function () { $news = Page::query()->where('book_id','95')->pluck('name')->join("\n"); // return view('home.news', $news) return response($news, 200, ['Content-Type' => 'text/plain']); }); }); } getnews(); ~~~ Maybe there is an easier way to display the pages. Thank you in advance.
Author
Owner

@ssddanbrown commented on GitHub (Sep 1, 2023):

@Man-in-Black You could use something like this within the visual theme system, when overriding the default homepage:

@php
$newsBookId = 95;
$newsItems = \BookStack\Entities\Models\Page::visible()
    ->where('book_id', $newsBookId)
    ->orderBy('created_at', 'desc')
    ->take(5)
    ->get();
@endphp
<div class="card mb-xl">
    <h3 class="card-title">Latest News</h3>
    <div class="px-m">
        @include('entities.list', [
            'entities' => $newsItems,
            'style' => 'compact',
        ])
    </div>
    <a href="{{ url('/books/my-news-book')  }}" class="card-footer-link">{{ trans('common.view_all') }}</a>
</div>

Be sure to change the link towards the bottom to match your Book URI. Could do this link dynamically based upon ID but not worth the extra homepage database query in my view.

@ssddanbrown commented on GitHub (Sep 1, 2023): @Man-in-Black You could use something like this within the visual theme system, when overriding the default homepage: ```blade @php $newsBookId = 95; $newsItems = \BookStack\Entities\Models\Page::visible() ->where('book_id', $newsBookId) ->orderBy('created_at', 'desc') ->take(5) ->get(); @endphp <div class="card mb-xl"> <h3 class="card-title">Latest News</h3> <div class="px-m"> @include('entities.list', [ 'entities' => $newsItems, 'style' => 'compact', ]) </div> <a href="{{ url('/books/my-news-book') }}" class="card-footer-link">{{ trans('common.view_all') }}</a> </div> ``` Be sure to change the link towards the bottom to match your Book URI. Could do this link dynamically based upon ID but not worth the extra homepage database query in my view.
Author
Owner

@Man-in-Black commented on GitHub (Sep 1, 2023):

@ssddanbrown
thanks very very much, it works like a charm ❤️
image
I know why I choosed to switch to bookstack in our company ;-)

@Man-in-Black commented on GitHub (Sep 1, 2023): @ssddanbrown thanks very very much, it works like a charm ❤️ ![image](https://github.com/BookStackApp/BookStack/assets/9048534/9c1a96fd-51eb-4a54-bf2b-bb55ae2cd1bf) I know why I choosed to switch to bookstack in our company ;-)
Author
Owner

@ssddanbrown commented on GitHub (Sep 1, 2023):

Good to hear that works for you! I'll therefore close this off since the request/use-case is covered via the customization.

@ssddanbrown commented on GitHub (Sep 1, 2023): Good to hear that works for you! I'll therefore close this off since the request/use-case is covered via the customization.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3971