Added book search.
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cover</th>
|
||||
<th>Id</th>
|
||||
<th></th>
|
||||
<th>Title</th>
|
||||
<th>Language</th>
|
||||
<th>Description</th>
|
||||
@@ -29,19 +28,23 @@
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
<tr>
|
||||
<td>{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}<img class="img-thumbnail"
|
||||
style="max-width: 80px"
|
||||
src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}" /> {% endif %}
|
||||
<td>
|
||||
{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}
|
||||
<a href="{{ path('app_book_show', {'id': book.id}) }}"><img class="img-thumbnail"
|
||||
style="max-width: 80px"
|
||||
src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}"/>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ book.id }}</td>
|
||||
<td>{{ book.Title }}</td>
|
||||
<td><a href="{{ path('app_book_show', {'id': book.id}) }}"
|
||||
class="text-decoration-none">{{ book.title }}</a></td>
|
||||
<td>{{ book.language }}</td>
|
||||
<td>{{ book.description | slice(0, 200) }}</td>
|
||||
<td>{{ book.publisher }}</td>
|
||||
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_book_show', {'id': book.id}) }}">show</a>
|
||||
<a href="{{ path('app_book_edit', {'id': book.id}) }}">edit</a>
|
||||
<a href="{{ path('app_book_show', {'id': book.id}) }}" class="text-decoration-none">show</a>
|
||||
<a href="{{ path('app_book_edit', {'id': book.id}) }}" class="text-decoration-none">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
||||
54
templates/book/search.html.twig
Normal file
54
templates/book/search.html.twig
Normal file
@@ -0,0 +1,54 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Book search{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="d-flex flex-row justify-content-between align-items-center">
|
||||
<div>
|
||||
<h1>Book search: {{ searchTerm }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Title</th>
|
||||
<th>Language</th>
|
||||
<th>Description</th>
|
||||
<th>Publisher</th>
|
||||
<th>Publish_date</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for book in books %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}
|
||||
<a href="{{ path('app_book_show', {'id': book.id}) }}"><img class="img-thumbnail"
|
||||
style="max-width: 80px"
|
||||
src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}"/>
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><a href="{{ path('app_book_show', {'id': book.id}) }}"
|
||||
class="text-decoration-none">{{ book.title }}</a></td>
|
||||
<td>{{ book.language }}</td>
|
||||
<td>{{ book.description | slice(0, 200) }}</td>
|
||||
<td>{{ book.publisher }}</td>
|
||||
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_book_show', {'id': book.id}) }}" class="text-decoration-none">show</a>
|
||||
<a href="{{ path('app_book_edit', {'id': book.id}) }}" class="text-decoration-none">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="9">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
@@ -3,33 +3,56 @@
|
||||
{% block title %}Book{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Book</h1>
|
||||
<div class="d-flex">
|
||||
|
||||
<div>
|
||||
|
||||
{% if file_exists(asset('book_covers/cover_' ~ book.id ~ '.jpg')) %}
|
||||
<img class="img-thumbnail"
|
||||
style="max-width: 80px"
|
||||
src="{{ asset('book_covers/cover_' ~ book.id ~ '.jpg' ) }}"/> {% endif %}
|
||||
</div>
|
||||
<div class="mx-3">
|
||||
<h1>{{ book.title }}</h1>
|
||||
<h3>{{ book.subtitle }}</h3>
|
||||
<p>{{ book.author }}</p>
|
||||
<p>{% for i in range(1, book.rating) %}⭐{% endfor %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ book.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<td>{{ book.Title }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Language</th>
|
||||
<td>{{ book.language }}</td>
|
||||
<th>Category</th>
|
||||
<td colspan="3">{{ book.category }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<td>{{ book.description | nl2br }}</td>
|
||||
<td colspan="3">{{ book.description | nl2br }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Publisher</th>
|
||||
<td>{{ book.publisher }}</td>
|
||||
<th>Publish date</th>
|
||||
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Publish_date</th>
|
||||
<td>{{ book.publishDate ? book.publishDate|date('Y-m-d') : '' }}</td>
|
||||
<th>Isbn</th>
|
||||
<td>{{ book.isbn }}</td>
|
||||
<th>Pages</th>
|
||||
<td>{{ book.pages }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Tags</th>
|
||||
<td colspan="3">{{ book.tags }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Series</th>
|
||||
<td colspan="3">{{ book.series }} {{ book.volume }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Language</th>
|
||||
<td colspan="3">{{ book.language }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user