template system: metadata on every page #3374

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

Originally created by @mb1811 on GitHub (Dec 1, 2022).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Exporting a single page as PDF adds some metadata to the end, with timestamp, editors name and version.

When you export a chapter or a book, none of these information is added to the individual page.

Is there a way to realize that within the template system? Just saw your video on adding header and footers - is there a way to get the metadata exported?

This code is found when exporting a singe page.

/resources/views/exports/page.blade.php

@include('pages.parts.page-display')

    <hr>

    <div class="text-muted text-small">
        @include('exports.parts.meta', ['entity' => $page])
    </div>

Exact BookStack Version

22.10.2

Log Content

No response

PHP Version

No response

Hosting Environment

Debian 11

Originally created by @mb1811 on GitHub (Dec 1, 2022). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Exporting a single page as PDF adds some metadata to the end, with timestamp, editors name and version. When you export a chapter or a book, none of these information is added to the individual page. Is there a way to realize that within the template system? Just saw your video on adding header and footers - is there a way to get the metadata exported? This code is found when exporting a singe page. /resources/views/exports/page.blade.php ``` @include('pages.parts.page-display') <hr> <div class="text-muted text-small"> @include('exports.parts.meta', ['entity' => $page]) </div> ``` ### Exact BookStack Version 22.10.2 ### Log Content _No response_ ### PHP Version _No response_ ### Hosting Environment Debian 11
OVERLORD added the 🐕 Support label 2026-02-05 06:32:03 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 1, 2022):

Hi @mb1811,

The page item template is used for pages within chapter/books exports: https://github.com/BookStackApp/BookStack/blob/development/resources/views/exports/parts/page-item.blade.php

You could override this with the visual theme system, then append the:

    <div class="text-muted text-small">
        @include('exports.parts.meta', ['entity' => $page])
    </div>

part to the template override to add the meta content for each page within chapter/book exports.

@ssddanbrown commented on GitHub (Dec 1, 2022): Hi @mb1811, The page item template is used for pages within chapter/books exports: https://github.com/BookStackApp/BookStack/blob/development/resources/views/exports/parts/page-item.blade.php You could override this with the visual theme system, then append the: ```html <div class="text-muted text-small"> @include('exports.parts.meta', ['entity' => $page]) </div> ``` part to the template override to add the meta content for each page within chapter/book exports.
Author
Owner

@mb1811 commented on GitHub (Dec 1, 2022):

Thank you very much!

<div class="page-break"></div>

@if (isset($chapter))
    <div class="chapter-hint">{{$chapter->name}}</div>
@endif

<h1 id="page-{{$page->id}}">{{ $page->name }}</h1>

<div class="text-muted text-small">
    @include('exports.parts.meta', ['entity' => $page])
</div>

{!! $page->html !!}

That looks much better. As we need to have a actual printout of our emergency handbook, this comes very handy!
Just need to figure out why the override in my template folder does not work.

Am I right to just copy

/resources/views/exports/parts/page-item.blade.php

to

/themes/mytheme/layouts/parts/

?

@mb1811 commented on GitHub (Dec 1, 2022): Thank you very much! ``` <div class="page-break"></div> @if (isset($chapter)) <div class="chapter-hint">{{$chapter->name}}</div> @endif <h1 id="page-{{$page->id}}">{{ $page->name }}</h1> <div class="text-muted text-small"> @include('exports.parts.meta', ['entity' => $page]) </div> {!! $page->html !!} ``` That looks much better. As we need to have a actual printout of our emergency handbook, this comes very handy! Just need to figure out why the override in my template folder does not work. Am I right to just copy /resources/views/exports/parts/page-item.blade.php to /themes/mytheme/layouts/parts/ ?
Author
Owner

@mb1811 commented on GitHub (Dec 1, 2022):

With that edit the version number is not printed when exporting the book.
When exporting the chapter the version number is visible.

@mb1811 commented on GitHub (Dec 1, 2022): With that edit the version number is not printed when exporting the book. When exporting the chapter the version number is visible.
Author
Owner

@ssddanbrown commented on GitHub (Dec 1, 2022):

Yeah, that data field does not exist in that context, since book contents are loaded in a different optimized way.

You may be able to update the @include line to be:

 @include('exports.parts.meta', ['entity' => \BookStack\Entities\Models\Page::query()->find($page->id)])

Not tested, and may slow things down.

@ssddanbrown commented on GitHub (Dec 1, 2022): Yeah, that data field does not exist in that context, since book contents are loaded in a different optimized way. You may be able to update the `@include` line to be: ```html @include('exports.parts.meta', ['entity' => \BookStack\Entities\Models\Page::query()->find($page->id)]) ``` Not tested, and may slow things down.
Author
Owner

@mb1811 commented on GitHub (Dec 12, 2022):

Thanks - works for me!

@mb1811 commented on GitHub (Dec 12, 2022): Thanks - works for me!
Author
Owner

@ssddanbrown commented on GitHub (Dec 12, 2022):

Good to hear, Will therefore close this off.

@ssddanbrown commented on GitHub (Dec 12, 2022): Good to hear, Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3374