[PR #2311] [CLOSED] added custom page header and page count footers to export #5979

Closed
opened 2026-02-05 10:21:45 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/2311
Author: @injektion
Created: 10/6/2020
Status: Closed

Base: masterHead: exportheaders


📝 Commits (1)

  • 136b6e4 added custom page header and page count footers to export

📊 Changes

5 files changed (+54 additions, -1 deletions)

View changed files

📝 resources/views/books/export.blade.php (+5 -0)
📝 resources/views/chapters/export.blade.php (+2 -0)
📝 resources/views/pages/export.blade.php (+2 -0)
resources/views/partials/export-header-footer.blade.php (+27 -0)
📝 resources/views/partials/export-styles.blade.php (+18 -1)

📄 Description

#493

[submitting as a PR for visibility/feedback]

Hey @ssddanbrown - I've pushed a branch ( https://github.com/injektion/BookStack/tree/exportheaders ) which might help with this... For exports, it'll display a page number in the footer and allow users to create a page to include as a header on every page.

Most of the juice is in partials/export-header-footer.blade.php which is now included in all the /views/[books|chapters|pages]/export.blade.php and checks for a couple .env variables

EXPORT_HEADER_PAGE_SLUG=header
EXPORT_SHOW_PAGE_NUMBERS=true

There's some extra CSS added to partials/export-styles.blade.php which sets up a counter for pages, and if the .env is true will drop it into a footer div

        .pagenum:before {
            content: counter(page);
        }

As for the header, I'm currently letting the user define a page as their header, and then in partials/export-header-footer.blade.php using the slug of that page to import a header....

@if(env("EXPORT_HEADER_PAGE_SLUG"))
<div class="header">
    @php
        $PAGE = new \BookStack\Entities\Page();
        $page = $PAGE::where("slug", "=", env("EXPORT_HEADER_PAGE_SLUG"))->first();
        $page->html = (new \BookStack\Entities\Managers\PageContent($page))->render();
    @endphp
    {!! $page->html !!}
</div>
@endif

It's working fine to allow the user to create their own headers, add some page numbering, and export, but I think there's probably a better flow to how to get the user to define the page to use as their header (configuration page?)... Do you have any recommendations on where you'd like to see the header get defined, or do you think this will work for those who want it? Additional features or configurations you'd need to include this?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/2311 **Author:** [@injektion](https://github.com/injektion) **Created:** 10/6/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `exportheaders` --- ### 📝 Commits (1) - [`136b6e4`](https://github.com/BookStackApp/BookStack/commit/136b6e429d6e4eaa679046b08d29dcdb4ede810a) added custom page header and page count footers to export ### 📊 Changes **5 files changed** (+54 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `resources/views/books/export.blade.php` (+5 -0) 📝 `resources/views/chapters/export.blade.php` (+2 -0) 📝 `resources/views/pages/export.blade.php` (+2 -0) ➕ `resources/views/partials/export-header-footer.blade.php` (+27 -0) 📝 `resources/views/partials/export-styles.blade.php` (+18 -1) </details> ### 📄 Description #493 [submitting as a PR for visibility/feedback] Hey @ssddanbrown - I've pushed a branch ( https://github.com/injektion/BookStack/tree/exportheaders ) which might help with this... For exports, it'll display a page number in the footer and allow users to create a page to include as a header on every page. Most of the juice is in partials/export-header-footer.blade.php which is now included in all the /views/[books|chapters|pages]/export.blade.php and checks for a couple .env variables ``` EXPORT_HEADER_PAGE_SLUG=header EXPORT_SHOW_PAGE_NUMBERS=true ``` There's some extra CSS added to partials/export-styles.blade.php which sets up a counter for pages, and if the .env is true will drop it into a footer div ``` .pagenum:before { content: counter(page); } ``` As for the header, I'm currently letting the user define a page as their header, and then in partials/export-header-footer.blade.php using the slug of that page to import a header.... ``` @if(env("EXPORT_HEADER_PAGE_SLUG")) <div class="header"> @php $PAGE = new \BookStack\Entities\Page(); $page = $PAGE::where("slug", "=", env("EXPORT_HEADER_PAGE_SLUG"))->first(); $page->html = (new \BookStack\Entities\Managers\PageContent($page))->render(); @endphp {!! $page->html !!} </div> @endif ``` It's working fine to allow the user to create their own headers, add some page numbering, and export, but I think there's probably a better flow to how to get the user to define the page to use as their header (configuration page?)... Do you have any recommendations on where you'd like to see the header get defined, or do you think this will work for those who want it? Additional features or configurations you'd need to include this? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:21:45 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5979