Wire up home search input to go to search page
This commit is contained in:
parent
32412c1172
commit
973a50ea9c
2 changed files with 10 additions and 1 deletions
|
@ -21,8 +21,13 @@ class HomePage(BasePage):
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_context(self, request: HttpRequest) -> dict:
|
def get_context(self, request: HttpRequest) -> dict:
|
||||||
|
from website.search.models import SearchPage
|
||||||
|
|
||||||
context = super().get_context(request)
|
context = super().get_context(request)
|
||||||
context["latest_blog_post"] = (
|
context["latest_blog_post"] = (
|
||||||
BlogPostPage.objects.live().defer_streamfields().order_by("-date").first()
|
BlogPostPage.objects.live().defer_streamfields().order_by("-date").first()
|
||||||
)
|
)
|
||||||
|
context["search_page"] = (
|
||||||
|
SearchPage.objects.all().live().defer_streamfields().first()
|
||||||
|
)
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
<main {% if page.image %}style="background-image: url({% image_url page.image 'width-1200' %})"{% endif %}>
|
<main {% if page.image %}style="background-image: url({% image_url page.image 'width-1200' %})"{% endif %}>
|
||||||
<div class="heading-wrapper">
|
<div class="heading-wrapper">
|
||||||
<h1>{{ page.heading }}</h1>
|
<h1>{{ page.heading }}</h1>
|
||||||
<input id="search-input" class="input" type="text" placeholder="Search">
|
{% if search_page %}
|
||||||
|
<form action="{% pageurl search_page %}">
|
||||||
|
<input id="search-input" class="input" type="text" placeholder="Search" name="q">
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if latest_blog_post %}
|
{% if latest_blog_post %}
|
||||||
|
|
Loading…
Reference in a new issue