Search Page
This commit is contained in:
parent
b294aba41a
commit
7526774a62
|
@ -121,7 +121,24 @@ ul.clearing-thumbs li {
|
|||
border: none;
|
||||
}
|
||||
|
||||
.related-row {
|
||||
padding: 5px 0px;
|
||||
.results {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.results-title {
|
||||
padding-top: 20px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.pagination a, .pagination button {
|
||||
color: #ffffff !important;
|
||||
}
|
||||
|
||||
.pagination a:hover,
|
||||
.pagination button:hover {
|
||||
background: #1779ba !important; }
|
||||
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
<div class="row related-row">
|
||||
<div class="small-6 columns">
|
||||
{% if content.image_url %}
|
||||
<img src="{{ content.image_url }}">
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}" class="sidebar-title"> {{content.title}} </a>
|
||||
{% if content.type.name == 'events' %}
|
||||
<h6 class="sidebar-date">
|
||||
<font color="#ef4e5c">
|
||||
<b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b>
|
||||
</font>
|
||||
{% if content.place %}<br/>{{content.place}}{% endif%}
|
||||
</h6>
|
||||
{% endif %}
|
||||
<p> {{ content.formatted_teaser }} </p>
|
||||
<div class="row">
|
||||
<div class="row right-items">
|
||||
<div class="small-6 columns">
|
||||
{% if content.image_url %}
|
||||
<img src="{{ content.image_url }}">
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<a href="{{ content.get_absolute_url }}" class="sidebar-title"> {{content.title}} </a>
|
||||
{% if content.type.name == 'events' %}
|
||||
<h6 class="sidebar-date">
|
||||
<font color="#ef4e5c">
|
||||
<b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b>
|
||||
</font>
|
||||
{% if content.place %}<br/>{{content.place}}{% endif%}
|
||||
</h6>
|
||||
{% endif %}
|
||||
<p> {{ content.formatted_teaser }} </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -3,10 +3,15 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="small-4 small-offset-2 columns results-title">
|
||||
<h3> Search results </h3>
|
||||
</div>
|
||||
</div>
|
||||
{% for content in results %}
|
||||
{% if content.type.name == 'news' %}
|
||||
<div class="row">
|
||||
<div class= "small-12 columns">
|
||||
<div class= "small-4 small-offset-2 columns">
|
||||
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{content.datestart}} </b>
|
||||
{{ content.title }} <br />
|
||||
{{ content.formatted_header|striptags|safe }} </font>
|
||||
|
@ -14,26 +19,53 @@
|
|||
</div>
|
||||
</div>
|
||||
{% elif content.type.name == 'events' %}
|
||||
<div class="row">
|
||||
<div class="small-6 columns">
|
||||
<div class="row results">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
<img src="{{ content.image_url }}">
|
||||
</div>
|
||||
<div class="small-6 columns">
|
||||
<div class="small-4 end columns">
|
||||
<a href="{{ content.get_absolute_url }}" class="sidebar-title">{{ content.title }}</a>
|
||||
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b></font> <br/>
|
||||
{{content.place}} </h6>
|
||||
<p> {{content.header|striptags|truncatechars:100|safe}} </p>
|
||||
<h6 class="sidebar-date"> <font color="#ef4e5c"> <b> {{ content.datestart }} {% if content.dateend %} - {{content.dateend}} {% endif %} </b></font>
|
||||
{% if content.place %}<br/> {{content.place}} {% endif%}</h6>
|
||||
<p> {{content.header|striptags|safe}} </p>
|
||||
<a href="{{ content.get_absolute_url }}">read more</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="small-4 small-offset-2 columns">
|
||||
Add view for content type: {{content.type}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<br>
|
||||
<br>
|
||||
{% if results.has_other_pages %}
|
||||
<div class="row">
|
||||
<div class="small-4 small-offset-4 columns">
|
||||
<ul class="pagination">
|
||||
{% if results.has_previous %}
|
||||
<li><a href="?page={{ results.previous_page_number }}">«</a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span>«</span></li>
|
||||
{% endif %}
|
||||
{% for i in results.paginator.page_range %}
|
||||
{% if results.number == i %}
|
||||
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
|
||||
{% else %}
|
||||
<li><a href="?page={{ i }}">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if results.has_next %}
|
||||
<li><a href="?page={{ results.next_page_number }}">»</a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span>»</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.http import HttpResponse, Http404
|
|||
from django.shortcuts import get_object_or_404, render, redirect
|
||||
from django.urls import reverse
|
||||
from django.views.generic.list import ListView
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from photologue.views import GalleryListView
|
||||
from photologue.models import Photo, Gallery
|
||||
|
@ -121,6 +122,15 @@ def page(request, shortname):
|
|||
def search(request):
|
||||
q = request.GET.get('q')
|
||||
results = Content.objects.filter(body__contains=q).order_by('-datestart')
|
||||
page = request.GET.get('page', 1)
|
||||
paginator = Paginator(results, 5)
|
||||
try:
|
||||
results = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
results = paginator.page(1)
|
||||
except EmptyPage:
|
||||
results = paginator.page(paginator.num_pages)
|
||||
|
||||
return render(request, 'results.html', {'results': results})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user