I’m having an issue with the current context with regards to multi-level menus.
I must preface this with the likely first response; I have read this:
And I still haven’t got a clue as to how to solve this.
First, some background -
there’s too much content for me to manage easily. Everything is in a database (data/data.json)
I’m manually configuring categories so that my layouts directory doesn’t get junked up - but as soon as I do that I run into this ‘current context’ issue.
The really strange part is that the page seems to reload but nothing on it changes. I hope to clarify this momentarily.
Here’s the important part of the config.toml:
(forgive the redundancy, I was just trying to figure out what’s going on)
[[menu.main]]
weight = 3
name = "Products"
url = "/products"
identifier = "products"
[[menu.main]]
parent = "products"
weight = 1
name = "All"
url = "/products/all/"
identifier = "allproducts"
[[menu.main]]
parent = "allproducts"
weight = 1
name = "Random"
url = "/products/all/random"
identifier = "randomproducts"
[[menu.main]]
parent = "products"
weight = 1
name = "Random"
url = "/products/random"
identifier = "random1"
[[menu.main]]
weight = 4
name = "Random"
url = "/random"
^^ This works, depending on the contents of the content dir being there. I’m just using ‘dummy files’ inside the content dir because .Site.Data.data is where the actual content is
So heres the content dir (more or less)
.
└── content
└── products // <- https://example.com/products/
| ├── random // <- https://example.com/products/random/
| | └── dummy.md
| ├── all // <- https://example.com/products/all/
| | ├── dummy.md
| | └── random // <- https://example.com/products/all/random/
| | └── dummy.md
| └── dummy.md
└── random // <- https://example.com/random/
└── dummy.md
^^ This works as far as URL paths are concerned, but the layout is giving me issues
(For brevity I’m only listing the essentials )
.
└── layouts
└── products
| ├── list.html
| ├── single.html
| ├── random
| | ├── list.html
| | └── single.html
| ├── all
| | ├── list.html
| | ├── single.html
| | └── random
| | ├── list.html
| | └── single.html
└── random
├── list.html
└── single.html
The list.html is the same for products
and all
layouts/products/list.html
{{ define "main" }}
{{ partial "products/list/product-list.html" . }}
{{ end }}
And the file referenced above:
layouts/partials/products/list/product-list.html
<div class="row">
{{ range (where .Site.Data.data ".Enable" "True" ) }}
{{ partial "products/list/product-list-item.html" . }}
{{ end }}
</div>
And all the ones for random
are the same
layouts/random/list.html
{{ define "main" }}
{{ partial "products/list/product-list-random.html" . }}
{{ end }}
And the file referenced above:
layouts/partials/products/list/product-list-random.html
<div class="row">
{{ range (shuffle (where .Site.Data.data ".Enable" "True" )) }}
{{ partial "products/list/product-list-item.html" . }}
{{ end }}
</div>
With this in mind, https://example.com/random/
and https://example.com/products/
both work correctly
https://example.com/products/random/
shows the same as https://example.com/products/
even though a different partial should be called.
It actually does nothing, that I can tell. The page attempts to reload if you navigate from
https://example.com/products/
to https://example.com/products/random/
but the same thing is displayed as was on the previous page. No errors are shown either, so debugging this has been a guessing game.
I know this is a current context issue, I’m just really not sure what to do about it or how to solve it. Many thanks in advance.