How to show 'pages' only in search result and how to add books to shelves without editing the shelves. #1954

Closed
opened 2026-02-05 02:19:03 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @JayRhithu on GitHub (Nov 25, 2020).

Hi Team,
Ubuntu 18.04
BookStack v0.30.2

Is there any features/customization available for my requests given below:

  1. On search results, showing 'books' and their containing 'pages'. Little confusion is there for a user that there are two books for the same topic searched. How to hide books in results and show 'pages' only in search result?
  2. Is there any method available to add books to shelves by a user without editing his/her shelves?

Pls help.

Originally created by @JayRhithu on GitHub (Nov 25, 2020). Hi Team, Ubuntu 18.04 BookStack v0.30.2 Is there any features/customization available for my requests given below: 1. On search results, showing 'books' and their containing 'pages'. Little confusion is there for a user that there are two books for the same topic searched. How to hide books in results and show 'pages' only in search result? 2. Is there any method available to add books to shelves by a user without editing his/her shelves? Pls help.
Author
Owner

@ssddanbrown commented on GitHub (Nov 26, 2020):

Hi @JayRhithu,

  1. When searching you should see filters in the sidebar where you can deselect all types apart from pages, if you only want to see pages:

image

  1. No, apart from initial creation. If you create a book from a shelf it will be added to the shelf when created. Otherwise you need to edit the shelf.
@ssddanbrown commented on GitHub (Nov 26, 2020): Hi @JayRhithu, 1. When searching you should see filters in the sidebar where you can deselect all types apart from pages, if you only want to see pages: ![image](https://user-images.githubusercontent.com/8343178/100290405-2b5a1300-2f73-11eb-9ba3-43885e1889c4.png) 2. No, apart from initial creation. If you create a book from a shelf it will be added to the shelf when created. Otherwise you need to edit the shelf.
Author
Owner

@JayRhithu commented on GitHub (Nov 26, 2020):

Hi, thanks for your reply.

I checked that option in sidebar. By default all options are enabled (page, chapter, book, shelf). How to enable 'page' only by default? I would like to give a choice to the user - like this:- while searching from the header, it should search in pages only, then if the user would like to know more, can select the other options like 'chapter, book, shelf' and do the search again.

@JayRhithu commented on GitHub (Nov 26, 2020): Hi, thanks for your reply. I checked that option in sidebar. By default all options are enabled (page, chapter, book, shelf). How to enable 'page' only by default? I would like to give a choice to the user - like this:- while searching from the header, it should search in pages only, then if the user would like to know more, can select the other options like 'chapter, book, shelf' and do the search again.
Author
Owner

@JayRhithu commented on GitHub (Dec 2, 2020):

Hi, any updates?

@JayRhithu commented on GitHub (Dec 2, 2020): Hi, any updates?
Author
Owner

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

Hi @JayRhithu,

There are no options within the app to configure the default active type filters as you want, Nor will I look to include any such controls due to this request being very specific.

That said, You could generally achieve what you're requesting by adding the below, Unofficial, script to the "Custom HTML Head Content" setting:

<script>
    document.addEventListener('DOMContentLoaded', function() {
        const onSearchPage = (window.location.pathname || '').split('/').pop() === 'search';
        if (onSearchPage) {
            return;
        }
        
        const searchInput = document.querySelector('input[name=term]');
        const searchForm = searchInput.closest('form');
        searchForm.addEventListener('submit', function() {
            searchInput.value += ' {type:page}';
        });
    });
</script>

This will add the page filter whenever someone submits that top search form, unless they're already on the search page.

@ssddanbrown commented on GitHub (Dec 12, 2020): Hi @JayRhithu, There are no options within the app to configure the default active type filters as you want, Nor will I look to include any such controls due to this request being very specific. That said, You could generally achieve what you're requesting by adding the below, Unofficial, script to the "Custom HTML Head Content" setting: ```html <script> document.addEventListener('DOMContentLoaded', function() { const onSearchPage = (window.location.pathname || '').split('/').pop() === 'search'; if (onSearchPage) { return; } const searchInput = document.querySelector('input[name=term]'); const searchForm = searchInput.closest('form'); searchForm.addEventListener('submit', function() { searchInput.value += ' {type:page}'; }); }); </script> ``` This will add the page filter whenever someone submits that top search form, unless they're already on the search page.
Author
Owner

@JayRhithu commented on GitHub (Dec 14, 2020):

Hi @ssddanbrown,
Thank you very much for your kind help. This is enough for me...

@JayRhithu commented on GitHub (Dec 14, 2020): Hi @ssddanbrown, Thank you very much for your kind help. This is enough for me...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1954