BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
14.89k stars 1.87k forks source link

Show Page Tags in Book/Chapter View #4704

Closed derekwelton closed 9 months ago

derekwelton commented 9 months ago

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?

How long have you been using BookStack?

Over 5 years

Additional context

No response

Man-in-Black commented 9 months ago

Did you mean something like that?

image
derekwelton commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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

ssddanbrown commented 9 months ago

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 commented 5 months ago

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 commented 4 months ago

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?