-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making Websites With October CMS - Part 41 - Ajax Frontend Filters
- Loading branch information
Ivan Dorić
authored and
Ivan Dorić
committed
Jul 15, 2017
1 parent
875b95d
commit bba912d
Showing
14 changed files
with
3,183 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+162 KB
themes/olympos/assets/fonts/vendor/semantic-ui-css/themes/default/icons.eot
Binary file not shown.
2,671 changes: 2,671 additions & 0 deletions
2,671
themes/olympos/assets/fonts/vendor/semantic-ui-css/themes/default/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+162 KB
themes/olympos/assets/fonts/vendor/semantic-ui-css/themes/default/icons.ttf
Binary file not shown.
Binary file added
BIN
+95.7 KB
themes/olympos/assets/fonts/vendor/semantic-ui-css/themes/default/icons.woff
Binary file not shown.
Binary file added
BIN
+75.4 KB
themes/olympos/assets/fonts/vendor/semantic-ui-css/themes/default/icons.woff2
Binary file not shown.
Binary file added
BIN
+27.5 KB
themes/olympos/assets/images/vendor/semantic-ui-css/themes/default/flags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
title = "Filter movies" | ||
url = "/ajax-filter" | ||
layout = "default" | ||
is_hidden = 0 | ||
|
||
== | ||
<? | ||
use Watchlearn\Movies\Models\Movie; | ||
use Watchlearn\Movies\Models\Genre; | ||
|
||
function onStart() { $this->prepareVars(); } | ||
function onFilterMovies() { $this->prepareVars(); } | ||
|
||
|
||
function prepareVars() { | ||
$options = post('Filter', []); | ||
|
||
$this['movies'] = Movie::listFrontEnd($options); | ||
$this['genres'] = Genre::all(); | ||
|
||
$movies = Movie::all(); | ||
$years = []; | ||
|
||
foreach($movies as $movie){ | ||
$years[] = $movie->year; | ||
} | ||
|
||
$years = array_unique($years); | ||
|
||
$this['years'] = $years; | ||
} | ||
|
||
?> | ||
== | ||
<h2 class="ui header" style="margin-top:40px;">Filter Movies</h2> | ||
|
||
<div class="ui grid"> | ||
|
||
<div class="five wide column"> | ||
{{ form_ajax('onFilterMovies', { update: { 'movies/movies': '#partialMovies' } }) }} | ||
<div id="MoviesFilter" class="movies-filter ui form"> | ||
<div class="ui segment vertical"> | ||
<label>Genres</label> | ||
{% for genre in genres %} | ||
<div class="field"> | ||
<div class="ui checkbox"> | ||
<input type="checkbox" name="Filter[genres][]" value="{{ genre.id }}" /> | ||
<label>{{genre.genre_title}}</label> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
|
||
<div class="field"> | ||
<label>Year</label> | ||
<select class="ui fluid dropdown" name="Filter[year]"> | ||
<option value="">Select Year</option> | ||
{% for year in years|sort %} | ||
<option value="{{year}}">{{ year }}</option> | ||
{% endfor %} | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
{{ form_close() }} | ||
</div> | ||
|
||
<div class="eleven wide column"> | ||
<div id="partialMovies"> | ||
{% partial 'movies/movies' %} | ||
</div> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% if movies|length %} | ||
|
||
{% for movie in movies %} | ||
<div class="ui segment vertical"> | ||
<h3 class="ui header">{{movie.name}}</h3> | ||
<div class="ui">{{ movie.year }}</div> | ||
|
||
<div class="ui segment"> | ||
<ul class="ui list bulleted horizontal"> | ||
{% for genre in movie.genres %} | ||
<li class="item">{{ genre.genre_title }}</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
|
||
{% else %} | ||
|
||
<div class="ui message text-center"> | ||
<p> | ||
There are no movies that match the criteria. | ||
</p> | ||
</div> | ||
|
||
{% endif %} |