我正在将 joomla 与 K2 一起使用,并且我想逐年在存档模块中订购新闻。当您单击“年份”时,它需要显示该年份的所有文章。Bit 模块还需要扩展 月过滤更深
如何修改模块以使其像这样?
问候
所以这就是我的意思
2012 - 一月 - 二月 - 三月 - 等等 2013 - 一月 - 二月 - 三月 - 等等
年份和月份都需要可过滤
如何修改模块以使其像这样?
问候
所以这就是我的意思
项目清单
- 2012
- 贾努阿里
- 二月
- 行进
等等等等
2013
- 贾努阿里
- 二月
- 行进
- 等等等等
年份和月份都需要可过滤
如何修改模块以使其像这样?
问候
<div id="k2ModuleBox<?php echo $module->id; ?>" class="k2ArchivesBlock<?php if($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); ?>">
<ul>
<?php foreach ($months as $month): ?>
<li>
<?php if ($params->get('archiveCategory', 0) > 0): ?>
<a href="<?php echo JRoute::_('index.php?option=com_k2&view=itemlist&task=date&month='.$month->m.'&year='.$month->y.'&catid='.$params->get('archiveCategory')); ?>">
<?php echo $month->name.' '.$month->y; ?>
<?php if ($params->get('archiveItemsCounter')) echo '('.$month->numOfItems.')'; ?>
</a>
<?php else: ?>
<a href="<?php echo JRoute::_('index.php?option=com_k2&view=itemlist&task=date&month='.$month->m.'&year='.$month->y); ?>">
<?php echo $month->name.' '.$month->y; ?>
<?php if ($params->get('archiveItemsCounter')) echo '('.$month->numOfItems.')'; ?>
</a>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
查询来自另一个文件
public static function getArchive(&$params)
{
$mainframe = JFactory::getApplication();
$user = JFactory::getUser();
$aid = (int)$user->get('aid');
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
$nullDate = $db->getNullDate();
$query = "SELECT DISTINCT MONTH(created) as m, YEAR(created) as y FROM #__k2_items WHERE published=1 AND ( publish_up = ".$db->Quote($nullDate)." OR publish_up <= ".$db->Quote($now)." ) AND ( publish_down = ".$db->Quote($nullDate)." OR publish_down >= ".$db->Quote($now)." ) AND trash=0";
if (K2_JVERSION != '15')
{
$query .= " AND access IN(".implode(',', $user->getAuthorisedViewLevels()).") ";
if ($mainframe->getLanguageFilter())
{
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND language IN (".$db->Quote($languageTag).", ".$db->Quote('*').") ";
}
}
else
{
$query .= " AND access<={$aid} ";
}
$catid = $params->get('archiveCategory', 0);
if ($catid > 0)
$query .= " AND catid=".(int)$catid;
$query .= " ORDER BY created DESC";
$db->setQuery($query);
$rows = $db->loadObjectList();
$months = array(JText::_('K2_JANUARY'), JText::_('K2_FEBRUARY'), JText::_('K2_MARCH'), JText::_('K2_APRIL'), JText::_('K2_MAY'), JText::_('K2_JUNE'), JText::_('K2_JULY'), JText::_('K2_AUGUST'), JText::_('K2_SEPTEMBER'), JText::_('K2_OCTOBER'), JText::_('K2_NOVEMBER'), JText::_('K2_DECEMBER'), );
if (count($rows))
{
foreach ($rows as $row)
{
if ($params->get('archiveItemsCounter'))
{
$row->numOfItems = modK2ToolsHelper::countArchiveItems($row->m, $row->y, $catid);
}
else
{
$row->numOfItems = '';
}
$row->name = $months[($row->m) - 1];
$archives[] = $row;
}
return $archives;
}
}