diff --git a/internal/pkg/dao/common.go b/internal/pkg/dao/common.go index 7168424..a9bda22 100644 --- a/internal/pkg/dao/common.go +++ b/internal/pkg/dao/common.go @@ -42,10 +42,15 @@ func CategoriesAndTags(a ...any) (terms []models.TermsMy, err error) { if !helper.GetContextVal(ctx, "showCountZero", false) { w = append(w, []string{"tt.count", ">", "0", "int"}) } + order := []string{"name", "asc"} + ord := helper.GetContextVal[[]string](ctx, "order", nil) + if ord != nil { + order = ord + } terms, err = model.Finds[models.TermsMy](ctx, model.Conditions( model.Where(w), model.Fields("t.term_id"), - model.Order(model.SqlBuilder{{"t.name", "asc"}}), + model.Order(model.SqlBuilder{order}), model.Join(model.SqlBuilder{ {"t", "inner join", "wp_term_taxonomy tt", "t.term_id = tt.term_id"}, }), diff --git a/internal/theme/wp/components/widget/category.go b/internal/theme/wp/components/widget/category.go index ac563df..a8a56e2 100644 --- a/internal/theme/wp/components/widget/category.go +++ b/internal/theme/wp/components/widget/category.go @@ -76,13 +76,8 @@ func Category(h *wp.Handle) string { return h.ComponentFilterFnHook(widgets.Categories, str.Replace(t, args)) } -func categoryUL(h *wp.Handle, args map[string]string, conf map[any]any, categories []models.TermsMy) string { - if slice.IsContained(h.CommonThemeMods().ThemeSupport.HTML5, "navigation-widgets") { - args["{$nav}"] = fmt.Sprintf(`" - } +func CategoryLi(h *wp.Handle, conf map[any]any, categories []models.TermsMy) string { s := str.NewBuilder() - s.WriteString("