Skip to content

Commit 980d224

Browse files
committed
fixes for category display
1 parent ee97274 commit 980d224

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

client/styles/global.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
max-height: 25em;
2222
overflow: hidden;
2323
}
24-
2524
.main.index .thumbnail img {
2625
height: 160px;
2726
}
2827

2928
/* PDP styles */
3029

30+
3131
.pdp.index img {
3232
width: 90%;
3333
}
3434

3535
/* Category styles */
3636
.category.index img {
37-
width: 64px;
37+
height: 3em;
3838
}

client/views/category-index.blade.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,31 @@
44

55
<div class="container category index">
66

7-
<div class="panel panel-info">
7+
<div class="panel panel-default">
88
<div class="panel-heading">
9-
<h1>Items with category: <strong class="text-primary">{{$category}}</strong></h1>
9+
<h2>Items with category:
10+
<div class="dropdown label">
11+
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
12+
{{$category}}
13+
<span class="caret"></span>
14+
</button>
15+
<ul class="dropdown-menu">
16+
@foreach( $categories as $cat)
17+
<li><a href="/category?category={{$cat}}">{{$cat}}</a></li>
18+
@endforeach
19+
</ul>
20+
</div>
21+
</h2>
1022
</div>
1123
<div class="panel-body">
24+
<div class="list-group">
1225
@foreach ( $products as $product )
13-
<div class="row">
14-
<div class="col-md-1">
15-
<img src='{{$product->image}}'>
16-
</div>
17-
<div class="col-md-8">
18-
<span>{{$product->name}}</span>
19-
</div>
20-
</div>
26+
<a href="/pdp?productId={{$product->id}}" class="list-group-item">
27+
<img src='{{$product->image}}'>
28+
<p class="list-group-item-text">{{$product->name}}</p>
29+
</a>
2130
@endforeach
31+
</div>
2232
</div>
2333
</div>
2434
</div>

server/ProductsCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getProductsWithCategory($categories) {
4444
foreach( $this->_productData as $product ) {
4545

4646
$common = array_intersect($product->categories, $categories);
47-
if ( array_count_values($common) > 0 ) {
47+
if ( count($common) > 0 ) {
4848
// there was at least one matching category
4949
array_push($products, $product);
5050
}
@@ -64,7 +64,7 @@ public function getAllCategories() {
6464
$categories = array_merge($categories, $product->categories);
6565
}
6666

67-
return $categories;
67+
return array_unique($categories);
6868
}
6969

7070
};

0 commit comments

Comments
 (0)