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

Add an empty block area on the search results listing. #5746

Merged
merged 1 commit into from Jan 20, 2020

Conversation

FlipperPA
Copy link
Contributor

@FlipperPA FlipperPA commented Dec 27, 2019

I had a requirement to add additional fields for a website to the admin search result listing. I accomplished this by overriding the entire template, but it would be much cleaner with a block in the template. Here's what I did:

{% load i18n wagtailadmin_tags %}

{# The title field for a page in the page listing, when in 'explore' mode #}

<div class="title-wrapper">
    {% if page.sites_rooted_here.exists %}
        {% if perms.wagtailcore.add_site or perms.wagtailcore.change_site or perms.wagtailcore.delete_site %}
            <a href="{% url 'wagtailsites:index' %}" class="icon icon-site" title="{% trans 'Sites menu' %}"></a>
        {% endif %}
    {% endif %}

    {% if page_perms.can_edit %}
        <a href="{% url 'wagtailadmin_pages:edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.get_admin_display_title }}</a>
    {% else %}
        {{ page.get_admin_display_title }}
    {% endif %}

    {# MEETING GUIDE: DISPLAY DAY OF WEEK AND ADDRESS, IF ON CURRENT PAGE #}
    {% if page.day_of_week >= 0 and page.day_of_week <= 6 %}
        ({{ page.get_day_of_week_display }})
    {% endif %}
    {% if page.formatted_address %}
        <br>{{ page.formatted_address }}
    {% endif %}
    {# END MEETING GUIDE MODIFICATIONS #}

    {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %}
    {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=page %}
</div>

<ul class="actions">
    {% page_listing_buttons page page_perms %}
</ul>

This PR adds an empty block area on the search results listing, for adding extra fields after the title (such as I have in this code between the {# MEETING GUIDE #} comments). Would this require a change in the documentation? I couldn't find anywhere appropriate.

Happy Holidays!

@squash-labs
Copy link

squash-labs bot commented Dec 27, 2019

Manage this branch in Squash

Test this branch here: https://flipperpaenhancementadd-page-l-722nk.squash.io

@loicteixeira
Copy link
Member

As discussed on Slack, I added the "need tests" label out of habit, but it doesn't seem that we do have tests for that kind of functionality, and the consensus is that it's not worth it, so I removed the label. Sorry for the confusion.

@FlipperPA
Copy link
Contributor Author

@loicteixeira No problem at all, I appreciate the diligence. Thanks!

@gasman gasman merged commit c4e5eb6 into wagtail:master Jan 20, 2020
@FlipperPA FlipperPA deleted the enhancement/add-page-listing-block branch April 18, 2020 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants