{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'category_detail' %}
{% set childCategories = repository('Eccube\\Entity\\Category').find(category.id).getDescendants() %}
{% block javascript %}
<script type="text/javascript">
$(function(){
$('.mod_movie-btn-favorite').on('click', function(){
let loginStatus = {{ is_granted('ROLE_USER') ? 'true' : 'false' }};
if(loginStatus){
let pid = $(this).data('pid');
let tmpbtn = $(this);
// tmpbtn.children("input").prop('disabled', true);
tmpbtn.children("input").attr('disabled', true);
if(tmpbtn.hasClass('favorite__del')){
$.ajax({
url: "{{ url('homepage') }}refine_delete_favorite",
type: 'GET',
dataType: 'text',
data: {id: pid}
})
.then(
function (data) {
tmpbtn.removeClass('favorite__del');
tmpbtn.addClass('favorite__add');
},
function () {
alert("処理に失敗しました。お手数ですが再度実行してください");
});
} else {
$.ajax({
url: "{{ url('homepage') }}products/add_favorite/"+pid,
type: 'POST',
})
.then(
function (data) {
tmpbtn.removeClass('favorite__add');
tmpbtn.addClass('favorite__del');
},
function () {
alert("処理に失敗しました。お手数ですが再度実行してください");
});
}
// tmpbtn.children("input").prop('disabled', false);
tmpbtn.children("input").attr('disabled', false);
} else {
location.href= "{{ url('mypage_delivery') }}";
}
});
// 表示件数を変更
$('.disp-number').change(function() {
var dispNumber = $(this).val();
$('#disp_number').val(dispNumber);
$('#pageno').val(1);
$("#form1").submit();
});
// 並び順を変更
$('.order-by').change(function() {
var orderBy = $(this).val();
$('#orderby').val(orderBy);
$('#pageno').val(1);
$("#form1").submit();
});
});
</script>
{% endblock %}
{% block stylesheet %}
<style>
.ec-searchnavRole {
margin-top: 30px;
}
</style>
{% endblock %}
{% block main %}
<div class="content__inner">
<div class="mod_breadcrumb">
<ul>
<li>
<a href="{{ url('homepage') }}">{{ 'ホーム'|trans }}</a>
</li>
<li>
<a href="{{ url('category_list') }}">{{ 'カテゴリ一覧'|trans }}</a>
</li>
{# 親カテゴリの設定 #}
{% set parentCategory = category.getParent %}
{% if parentCategory is not empty %}
<li><a href="{{ url('categories/{category_id}', { 'category_id': parentCategory.id }) }}">{{ parentCategory.name|trans }}</a></li>
{% endif %}
<li>
<span>{{ category.name|trans }}</span>
</li>
</ul>
</div>
<form name="form1" id="form1" method="get" action="?">
{% for item in search_form %}
<input type="hidden" id="{{ item.vars.id }}"
name="{{ item.vars.full_name }}"
{% if item.vars.value is not empty %}value="{{ item.vars.value }}" {% endif %}/>
{% endfor %}
</form>
<div class="page__content">
<h1>{{ category.name|trans }}</h1>
<div class="page__inner">
<div class="ec-searchnavRole" style="padding: 0;margin-top:0;">
<div class="ec-searchnavRole__infos" style="border: none;padding-top:0;">
<div class="ec-searchnavRole__counter">
{% if pagination.totalItemCount > 0 %}
{{ '<span class="ec-font-bold">%count%件</span><span>の動画が見つかりました</span>'|trans({ '%count%': pagination.totalItemCount })|raw }}
{% else %}
<span>{{ 'お探しの動画は見つかりませんでした'|trans }}</span>
{% endif %}
</div>
{% if pagination.totalItemCount > 0 %}
<div class="ec-searchnavRole__actions">
<div class="ec-select">
{{ form_widget(disp_number_form, {'id': '', 'attr': {'class': 'disp-number'}}) }}
{{ form_widget(order_by_form, {'id': '', 'attr': {'class': 'order-by'}}) }}
</div>
</div>
{% endif %}
</div>
</div>
{% if childCategories is defined and childCategories|length > 0 %}
{# 表示用計算 #}
{% set cntTotalPublished = 0 %}
{% for childCategory in childCategories %}
{# サブスクリプション, 新入荷, 講師は除く #}
{% if childCategory.id != 7 and childCategory.id != 2 and childCategory.id != 64 %}
{# 公開のみカウント #}
{% if childCategory.ProductCategories is not empty %}
{% for ProductCategory in childCategory.ProductCategories %}
{% set cntTotalPublished = cntTotalPublished + (ProductCategory.Product is not empty and ProductCategory.Product.Status.id == 1 ? 1 : 0) %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{# カテゴリに紐付いた記事があれば表示 #}
{% if (cntTotalPublished > 0) %}
<div class="mod_inpage-link">
<h5>{{ 'さらに絞り込んで表示する'|trans }}</h5>
<ul>
{% for childCategory in childCategories %}
{# サブスクリプション, 新入荷, 講師は除く #}
{% if childCategory.id != 7 and childCategory.id != 2 and childCategory.id != 64 %}
{% set cntPublished = 0 %}
{# 公開のみカウント #}
{% if childCategory.ProductCategories is not empty %}
{% for ProductCategory in childCategory.ProductCategories %}
{% set cntPublished = cntPublished + (ProductCategory.Product is not empty and ProductCategory.Product.Status.id == 1 ? 1 : 0) %}
{% endfor %}
{% endif %}
{% if (cntPublished > 0) %}
<li>
<a href="{{ url('categories/{category_id}', { 'category_id': childCategory.id }) }}">{{ childCategory.name|trans }}</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
{% endif %}
{% if pagination is defined and pagination.totalItemCount > 0 %}
<ul class="mod_movie-list">
{% for item in pagination %}
{% set productClass = item.ProductClasses.get(0) %}
{% set videoContent = productClass.ProductClassContent.get(0) %}
{# 通常は動画閲覧画面、コンテンツがない場合は商品詳細へ #}
{% if videoContent is not empty %}
{% set anker = url('video/{product_id}/content/{content_id}', {'product_id': item.id, 'content_id': videoContent.Content.id}) %}
{% else %}
{% set anker = url('product_detail', {id: item.id}) %}
{% endif %}
{% set isFavorite = customer is not empty and repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(customer, item) %}
<li class="mod_movie-item">
<div class="mod_movie-item-inner">
<div class="mod_movie-img-wrapper">
<a href="{{ anker }}">
{% if item.ProductImage is defined and item.ProductImage is not empty %}
<img src="{{ asset(item.ProductImage.get(0), 'save_image') }}" alt="Product.name" />
{% else %}
<img src="{{ asset(''|no_image_product, 'save_image') }}" alt="" />
{% endif %}
</a>
</div>
<div class="mod_movie-text-wrapper">
<a href="{{ anker }}" class="mod_movie-title">{{ item.name|trans }}</a>
{% set searchWords = item.search_word|split(',') %}
<ul class="mod_movie-keyword-list">
{% for word in searchWords %}
{% if word is not empty %}
<li class="mod_movie-keyword-item">
<span>{{ word|trans }}</span>
</li>
{% endif %}
{% endfor %}
</ul>
<div class="mod_movie-btn-wrapper">
<div class="mod_movie-btn-favorite {{ (isFavorite == 1) ? 'favorite__del': 'favorite__add' }}" data-pid="{{ item.id }}">
{# 一旦全部見たい授業とする #}
{# {% if isFavorite and false %}
<form action="{{ url('refine_delete_favorite', {id:item.id}) }}" method="post">
<input type="submit" value="{{ '見たい授業'|trans }}" />
</form>
{% else %}
<form action="{{ url('product_add_favorite', {id:item.id}) }}" method="post">
<input type="submit" value="{{ '見たい授業'|trans }}" />
</form>
{% endif %} #}
{# {% if isFavorite == 1 %} #}
<input type="button" class="favorite-btn" value="{{ '見たい授業'|trans }}" />
{# {% else %}
<input type="button" class="favorite-btn" value="{{ '見たい授業'|trans }}" />
{% endif %} #}
</div>
<a href="{{ anker }}" class="mod_movie-btn-watch">
<span>{{ '見る'|trans }}</span>
</a>
</div>
</div>
</div>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% include "category_pager.twig" with {'pages': pagination.paginationData} %}
<div class="page__inner">
<h2 class="mod_movie-h2">
{{ 'カテゴリ一覧'|trans }}
</h2>
<div class="mod_movie-btn-more">
<a href="{{ url('category_list') }}">{{ 'カテゴリ一覧に戻る'|trans }}</a>
</div>
</div>
</div>
</div>
{% endblock %}