mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
News Archive Menu added. e-expandit now adds the 'open' css class when expanded.
This commit is contained in:
@@ -11,4 +11,6 @@ define("TD_MENU_L2", "Other News");
|
||||
|
||||
define("LAN_NEWSCAT_MENU_TITLE", "News Categories");
|
||||
define("LAN_NEWSLATEST_MENU_TITLE", "Latest News");
|
||||
define("LAN_NEWSARCHIVE_MENU_TITLE", "News Archive");
|
||||
|
||||
?>
|
78
e107_plugins/news/news_archive_menu.php
Normal file
78
e107_plugins/news/news_archive_menu.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2017 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$nw = e107::getObject('e_news_tree');
|
||||
$tp = e107::getParser();
|
||||
|
||||
$tmp = $nw->loadJoinActive()->toArray();
|
||||
|
||||
$monthLabels = e107::getDate()->terms();
|
||||
|
||||
$arr = array();
|
||||
foreach($tmp as $id => $val)
|
||||
{
|
||||
$d = date('Y-n',$val['news_datestamp']);
|
||||
list($year,$month) = explode('-',$d);
|
||||
$arr[$year][$month][] = $val;
|
||||
}
|
||||
|
||||
$text = "<ul class='news-archive-menu'>";
|
||||
|
||||
foreach($arr as $year=>$val)
|
||||
{
|
||||
if($year == date('Y'))
|
||||
{
|
||||
$displayYear = 'block';
|
||||
$expandOpen = 'open';
|
||||
}
|
||||
else
|
||||
{
|
||||
$displayYear = 'none';
|
||||
$expandOpen = '';
|
||||
}
|
||||
|
||||
$id = "news-archive-".$year;
|
||||
$text .= "<li>";
|
||||
$text .= "<a class='e-expandit {$expandOpen}' href='#".$id."'>".$year."</a>";
|
||||
$text .= "<ul id='".$id."' class='news-archive-menu-months' style='display:".$displayYear."'>";
|
||||
|
||||
foreach($val as $month=>$items)
|
||||
{
|
||||
//$displayMonth = ($mCount === 1) ? 'display:block': 'display:none';
|
||||
|
||||
$idm = "news-archive-".$month;
|
||||
|
||||
$text .= "<li >";
|
||||
$text .= "<a class='e-expandit' href='#".$idm."'>".$monthLabels[$month]."</a>";
|
||||
$text .= "<ul id='".$idm."' class='news-archive-menu-items' style='display:none'>";
|
||||
|
||||
foreach($items as $row)
|
||||
{
|
||||
$url = e107::getUrl()->create('news/view/item', $row, array('allow' => 'news_sef,news_title,news_id,category_sef,category_name,category_id'));
|
||||
$text .= "<li><a href='".$url."'>".$tp->toHtml($row['news_title'],false,'TITLE')."</a></li>";
|
||||
|
||||
}
|
||||
$text .= "</ul>";
|
||||
$text .= "</li>";
|
||||
|
||||
}
|
||||
$text .= "</ul>";
|
||||
$text .= "</li>";
|
||||
|
||||
}
|
||||
$text .= "</ul>";
|
||||
|
||||
e107::plugLan('news');
|
||||
|
||||
e107::getRender()->tablerender(LAN_NEWSARCHIVE_MENU_TITLE, $text);
|
||||
|
||||
e107::getDebug()->log($arr);
|
||||
|
@@ -539,6 +539,32 @@ img.news-image-1 { margin-bottom:15px }
|
||||
.btn-sm { font-size: 0.8em }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ul.news-archive-menu li { list-style:none; }
|
||||
ul.news-archive-menu li a:hover,
|
||||
ul.news-archive-menu li a:active,
|
||||
ul.news-archive-menu li a:focus { text-decoration:none }
|
||||
|
||||
ul.news-archive-menu li a:before { content: '► '}
|
||||
ul.news-archive-menu li a.e-expandit.open:before { content: '▼ '}
|
||||
ul.news-archive-menu-months li a.e-expandit.open:before { content: '▼ '}
|
||||
ul.news-archive-menu-items li a:before { content: '' }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Extra small devices Phones (<768px) .col-xs */
|
||||
@media all and (max-width: 767px) {
|
||||
|
||||
|
@@ -212,6 +212,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
// default 'toggle'.
|
||||
$(this).click(function ()
|
||||
{
|
||||
|
||||
var $this = $(this);
|
||||
var href = ($this.is("a")) ? $this.attr("href") : '';
|
||||
var $button = $this.find('button');
|
||||
@@ -264,6 +265,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
{
|
||||
if($(this).is(':visible'))
|
||||
{
|
||||
$this.addClass('open');
|
||||
if($this.hasClass('e-expandit-inline'))
|
||||
{
|
||||
$(this).css('display', 'initial');
|
||||
@@ -273,6 +275,10 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
$(this).css('display', 'block'); //XXX 'initial' broke the default behavior.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.removeClass('open');
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user