Browse Source

Front-end, better left sidebar cats

Vova Tkach 5 years ago
parent
commit
56cc00c581

+ 12 - 4
assets/template/sidebar_left_html_file.go

@@ -4,10 +4,18 @@ var VarSidebarLeftHtmlFile = []byte(`<div class="card mb-4">
 	<h5 class="card-header">Shop categories</h5>
 	<div class="card-body">
 		<ul class="m-0 p-0 pl-4">
-			{{range $.Data.Shop.Categories 0 1}}
-				<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
-					<a href="{{.Permalink}}">{{.Name}}</a>
-				</li>
+			{{if $.Data.Shop.Category}}
+				{{range $.Data.Shop.Categories $.Data.Shop.Category.Id 1}}
+					<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
+						<a href="{{.Permalink}}">{{.Name}}</a>
+					</li>
+				{{end}}
+			{{else}}
+				{{range $.Data.Shop.Categories 0 1}}
+					<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
+						<a href="{{.Permalink}}">{{.Name}}</a>
+					</li>
+				{{end}}
 			{{end}}
 		</ul>
 	</div>

+ 12 - 4
hosts/localhost/template/sidebar-left.html

@@ -2,10 +2,18 @@
 	<h5 class="card-header">Shop categories</h5>
 	<div class="card-body">
 		<ul class="m-0 p-0 pl-4">
-			{{range $.Data.Shop.Categories 0 1}}
-				<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
-					<a href="{{.Permalink}}">{{.Name}}</a>
-				</li>
+			{{if $.Data.Shop.Category}}
+				{{range $.Data.Shop.Categories $.Data.Shop.Category.Id 1}}
+					<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
+						<a href="{{.Permalink}}">{{.Name}}</a>
+					</li>
+				{{end}}
+			{{else}}
+				{{range $.Data.Shop.Categories 0 1}}
+					<li class="{{if and $.Data.Shop.Category (eq $.Data.Shop.Category.Id .Id)}}active{{end}}">
+						<a href="{{.Permalink}}">{{.Name}}</a>
+					</li>
+				{{end}}
 			{{end}}
 		</ul>
 	</div>