♻️ Handle tags in MenuHelper
This commit is contained in:
parent
8e406fd8ba
commit
063751a568
3 changed files with 23 additions and 13 deletions
|
@ -20,13 +20,18 @@ class MenuHelper {
|
|||
return MenuHelper::toMenu($archives->getLinkList($monthly, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
|
||||
public static function getCategories($showEmpty, $showCount, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $categories;
|
||||
return MenuHelper::toMenu($categories->getLinkList($showEmpty, $showCount, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
public static function getTags($minArticle = 1, $classUl = "", $classLink = "", $classActive = "active", $include = "")
|
||||
{
|
||||
global $tags;
|
||||
return MenuHelper::toMenu($tags->getLinkList($minArticle, $classLink, $classActive), $classUl, $include);
|
||||
}
|
||||
|
||||
private static function toMenu($links, $classUl, $include = "")
|
||||
{
|
||||
$html = '<ul '. ($classUl != '' ? 'class="'.$classUl.'"' : '') .'>';
|
||||
|
|
|
@ -36,4 +36,20 @@ class Tags extends dbList {
|
|||
return $this->save();
|
||||
}
|
||||
|
||||
public function getLinkList($minArticles = 1, $class = "", $classActive = "active")
|
||||
{
|
||||
$listLink = array();
|
||||
foreach ($this->db as $pageKey=>$pageFields) {
|
||||
$count = count($pageFields['list']);
|
||||
if (
|
||||
($count >= $minArticles)
|
||||
) {
|
||||
$link = DOMAIN_TAGS . $pageKey;
|
||||
$name = $pageFields['name'];
|
||||
$listLink[] = new Link($name, $link, $class, $classActive);
|
||||
}
|
||||
}
|
||||
return $listLink;
|
||||
}
|
||||
|
||||
}
|
|
@ -34,18 +34,7 @@ class pluginTags extends Plugin
|
|||
$html = '<div class="plugin plugin-tags">';
|
||||
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
|
||||
$html .= '<div class="plugin-content">';
|
||||
$html .= '<ul class="flat-list">';
|
||||
|
||||
// By default the database of tags are alphanumeric sorted
|
||||
foreach ($tags->db as $key => $fields) {
|
||||
$html .= '<li>';
|
||||
$html .= '<a href="' . DOMAIN_TAGS . $key . '">';
|
||||
$html .= $fields['name'];
|
||||
$html .= '</a>';
|
||||
$html .= '</li>';
|
||||
}
|
||||
|
||||
$html .= '</ul>';
|
||||
$html .= MenuHelper::getTags(1, "flat-list");
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue