Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Page Tags in Book/Chapter View #4704

Closed
1 task done
derekwelton opened this issue Nov 30, 2023 · 9 comments
Closed
1 task done

Show Page Tags in Book/Chapter View #4704

derekwelton opened this issue Nov 30, 2023 · 9 comments

Comments

@derekwelton
Copy link

derekwelton commented Nov 30, 2023

Describe the feature you'd like

Currently in the Search Results, It shows the Tags associated with that page like below:

image

But I wish we could see the tags when we have a "Book" view or Chapter opened that showed the tags. Currently it does not:

image

Describe the benefits this would bring to existing BookStack users

I believe having tags more available in other views besides Search and viewing the page itself gives the users a better idea on what each page contains without having to go into each page. One method we use tags for is to tag pages that need to be reviewed. Having the ability to go into each Book and see from a glance which pages/chapters have the "need review" tag.

Another approach to solving my issue is having the ability to filter pages that do not have a specific tag as well.

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

Since the search results view already has this feature implemented, I assume it wouldn't take too much effort to implement this.

Have you searched for an existing open/closed issue?

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

How long have you been using BookStack?

Over 5 years

Additional context

No response

@Man-in-Black
Copy link
Contributor

Did you mean something like that?
image

@derekwelton
Copy link
Author

Did you mean something like that? image

Yes, exactly like that. How is that done? I've looked through the settings, is this in the config file to enable?

@Man-in-Black
Copy link
Contributor

no, I've done it via the visual theme system by modifying some of the php files of the application.
I can write a little guide tomorrow.

@Man-in-Black
Copy link
Contributor

Man-in-Black commented Dec 2, 2023

Alright...
For the pages to show the tags (and on top if it is a template or not) you need to edit the pages/parts/list-item.blade.php file in your theme folder.
I've changed the file from

@component('entities.list-item-basic', ['entity' => $page])
    <div class="entity-item-snippet">
        <p class="text-muted break-text">{{ $page->getExcerpt() }}</p>
    </div>
@endcomponent

to

@component('entities.list-item-basic', ['entity' => $page])
    <div class="entity-item-snippet">
        <p class="text-muted break-text">
            <!-- added for template marking -->
            @if($page->template)
                @icon('template')
            @endif
            <!-- end template marking -->
            {{ $page->getExcerpt() }}
            <!-- show tags -->
            @if($page->tags->count() > 0)
                @foreach($page->tags as $tag)
                    @include('entities.tag-page-list', ['tag' => $tag])
                @endforeach
            @endif
            <!-- end show tags -->
        </p>
    </div>
@endcomponent

so you get the view as shown above and on top templates are marked with a template symbol like this:
image

@derekwelton
Copy link
Author

Alright... For the pages to show the tags (and on top if it is a template or not) you need to edit the pages/parts/list-item.blade.php file in your theme folder. I've changed the file from

@component('entities.list-item-basic', ['entity' => $page])
    <div class="entity-item-snippet">
        <p class="text-muted break-text">{{ $page->getExcerpt() }}</p>
    </div>
@endcomponent

to

@component('entities.list-item-basic', ['entity' => $page])
    <div class="entity-item-snippet">
        <p class="text-muted break-text">
            <!-- added for template marking -->
            @if($page->template)
                @icon('template')
            @endif
            <!-- end template marking -->
            {{ $page->getExcerpt() }}
            <!-- show tags -->
            @if($page->tags->count() > 0)
                @foreach($page->tags as $tag)
                    @include('entities.tag-page-list', ['tag' => $tag])
                @endforeach
            @endif
            <!-- end show tags -->
        </p>
    </div>
@endcomponent

so you get the view as shown above and on top templates are marked with a template symbol like this: image

Excellent example. Thank you for taking the time to share it. Works as expected. Thanks again!

@Man-in-Black
Copy link
Contributor

I'm happy if I could help you with this little tweak ;-)

@ssddanbrown
Copy link
Member

Thanks @Man-in-Black for helping provide a workaround here.
Since this has been solved via a workaround, and since I'm not keen to expand tags into this view, I'm going to close this off.
There's #4536 which would additionally help the original request via the alternative option of searching for content without specific tags.

@GuillaumeV-cemea
Copy link

Hi,

I'm running v24.02.2, but your workaround was not working, I had the following error in laravel.log : [previous exception] [object] (InvalidArgumentException(code: 0): View [entities.tag-page-list] not found. at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php:137)

I updated it to the following and it now works :

@component('entities.list-item-basic', ['entity' => $page])
    <div class="entity-item-snippet">
        <p class="text-muted break-text">
            <!-- added for template marking -->
            @if($page->template)
                @icon('template')
            @endif
            <!-- end template marking -->
            {{ $page->getExcerpt() }}
            <!-- show tags -->
            @if($page->tags->count() > 0)
	    <div class="entity-item-tags mt-xs">
		@include('entities.tag-list', ['entity' => $page, 'linked' => false ])
	    </div>
            @endif
            <!-- end show tags -->
        </p>
    </div>
@endcomponent

@nesges
Copy link
Contributor

nesges commented May 25, 2024

This helped me solve an issue, thanks! I'm curious: is it possible to extend this to display a clickable tagcloud/sorted list of unique tags above the list of pages in a book?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants