Browse Source

menu sort support for theme tajian

master
filesite 1 year ago
parent
commit
3edb407fcc
  1. 12
      themes/tajian/controller/ListController.php
  2. 27
      themes/tajian/controller/SiteController.php

12
themes/tajian/controller/ListController.php

@ -38,16 +38,14 @@ Class ListController extends SiteController { @@ -38,16 +38,14 @@ Class ListController extends SiteController {
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme);
}
//排序
$sortedTree = $this->sortMenusAndDirTree($menus_sorted, $menus, $dirTree);
if (!empty($sortedTree)) {
$menus = $sortedTree['menus'];
$dirTree = $sortedTree['dirTree'];
}
//获取tags分类
$tags = $this->getTags($dirTree);
//排序
if (!empty($menus_sorted) && !empty($tags)) {
$tags = $this->sortTags($menus_sorted, $tags);
}
//获取目录面包屑
$tagId = $cateId = $this->get('id', '');
$tagItem = $tags[$tagId];

27
themes/tajian/controller/SiteController.php

@ -38,13 +38,6 @@ Class SiteController extends Controller { @@ -38,13 +38,6 @@ Class SiteController extends Controller {
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme);
}
//排序
$sortedTree = $this->sortMenusAndDirTree($menus_sorted, $menus, $dirTree);
if (!empty($sortedTree)) {
$menus = $sortedTree['menus'];
$dirTree = $sortedTree['dirTree'];
}
//默认显示的目录
$cateId = $this->get('id', $menus[0]['id']);
$subcate = $scanResults[$cateId];
@ -61,6 +54,11 @@ Class SiteController extends Controller { @@ -61,6 +54,11 @@ Class SiteController extends Controller {
//获取tags分类
$tags = $this->getTags($dirTree);
//排序
if (!empty($menus_sorted) && !empty($tags)) {
$tags = $this->sortTags($menus_sorted, $tags);
}
$pageTitle = $defaultTitle = !empty($titles) ? $titles[0]['name'] : FSC::$app['config']['site_name'];
if (!empty($subcate)) {
@ -117,4 +115,19 @@ Class SiteController extends Controller { @@ -117,4 +115,19 @@ Class SiteController extends Controller {
return $tag;
}
protected function sortTags($menus_sorted, $tags) {
$sorted_tags = array();
foreach($menus_sorted as $tag) {
foreach($tags as $id => $item) {
if ($item['name'] == $tag) {
$sorted_tags[$id] = $item;
}
}
}
return $sorted_tags;
}
}

Loading…
Cancel
Save