- Posts: 12
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] K2 Tools archive module sort by year than month
[SOLVED] K2 Tools archive module sort by year than month
- Wouter
-
Topic Author
- Offline
- New Member
So this is what I mean
2012
- Januari
- Februari
- March
- etc etc
2013
- Januari
- Februari
- March
- etc etc.
Both year and month needs to be filterable
How can I modify the module to act like This?
Greets
Please Log in or Create an account to join the conversation.
- Wouter
-
Topic Author
- Offline
- New Member
- Posts: 12
Please Log in or Create an account to join the conversation.
- Wouter
-
Topic Author
- Offline
- New Member
- Posts: 12
<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>
The query is from another file
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;
}
}
Please Log in or Create an account to join the conversation.
- artyom
-
- Offline
- New Member
- Posts: 1
Please Log in or Create an account to join the conversation.
- Axel
-
- Offline
- New Member
- Posts: 6
so
2013
-jan
-feb
...
2012
-jan
-feb
...
etc. But the months only show when you press the year. I have an archive showing jan-dec for 2010 - 2013 now, thats a very long list :D
Is there a plugin/module to achieve this or can it be done by simply changing the archive.php some easy way?
Please Log in or Create an account to join the conversation.
- Axel
-
- Offline
- New Member
- Posts: 6
Here is a working example of the nested months under years (on the right side under title "ARKIV")
So this is what I came up with as a working solution on this subject (for my current needs).
Thanks to the answer on stackoverflow combined with JQuerry accordion widget I was able to put together the following code
archive.php – Copy (don't move) this file from
SITEROOT/modules/mod_k2_tools/tmpl/
to
SITEROOT/templates/YOURTEMPLATE/html/mod_k2_tools/)
for sake of ease, select all and paste the following
GANTRY
with
LESS CSS
and
FontAwesome
here, so if your using another base, you'll need to modify the CSS a bit ;)
I would also suggest using the minified version of the JQuerry UI for this.
You can download the same settings I used here
or just reset and chose the ones you want.
PS. Don't forget to change "YOURTEMPLATE" to your actual template name ;) DS
Please Log in or Create an account to join the conversation.
- Axel
-
- Offline
- New Member
- Posts: 6
What I would like to achieve now is the following structure
-YEAR 1
-- month 1
--- post 1
--- post 2
--- post 3
-- month 2
--- post 1
--- post 2
--- post 3
-YEAR 2
-- month 1
--- post 1
--- post 2
--- post 3
-- month 2
--- post 1
--- post 2
--- post 3
etc.
So, basically what I have, just adding another list of items posted (with the title of the item) under each month :)
Like I said, any help on this is greatly appreciated. I will post the final code here (unless *crossing fingers* someone else beats me to it :woohoo:)
Please Log in or Create an account to join the conversation.
- Balgas
-
- Offline
- Junior Member
I've installed your method for archives but it seems to have a conflict of jquery on my page...
My galery doesn't work :(
the ink : www.mycreaweb.fr/zakhor/manifestations.html
I use joomla 2.5.11 & K2 2.6.7
Thx for your help
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
If you are experiencing JS Conflicts you should try the methods described here api.jquery.com/jQuery.noConflict .
Please Log in or Create an account to join the conversation.
- Balgas
-
- Offline
- Junior Member
How can i have no conflict beetween jquery ? I test your link, but i can't find the solution...
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You can always choose 1.8 or 1.7 through K2's parameters.
As for the nocoflict you can use the Example: Create a different alias instead of jQuery to use in the rest of the script.
var j = jQuery.noConflict();
j(function() {
j( "#k2-archive-heading" ).accordion({ heightStyle: "content" });
});
Also you are loading the script from your localhost, you must change the source to it's correct location.
Finally loading scripts should be done with the Joomla! API. More on this can be found here docs.joomla.org/JDocument/addScript
Please Log in or Create an account to join the conversation.
- Balgas
-
- Offline
- Junior Member
I delete the script : <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
& load on K2 jquery v.1.9.0 & it's work !
Thx a lot !!!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Also you are loading the script from your localhost, you must change the source to it's correct location.
Make sure you 've corrected that too because it will crash in all other users.
Please Log in or Create an account to join the conversation.
- Balgas
-
- Offline
- Junior Member
Please Log in or Create an account to join the conversation.
- Federico Falciani
-
- Offline
- New Member
- Posts: 3
Waiting for your response.
Thank you very much.
Federico.
Please Log in or Create an account to join the conversation.
- Paul76
-
- Offline
- New Member
- Posts: 1
Please Log in or Create an account to join the conversation.
- Alaa
-
- Offline
- New Member
- Posts: 3
Thank you indeed for your input. Please the solution didn't work on my site. The year appears but with no style and no animation! I think the JQuery didn't work. Do I have to do something to import the JQuiry animation? Can anyone just upload the file of JQuery that I should use?
Please help me. I really like this and need it.
I don't know anything about JS and JQuery.
Thank you advance.
Please Log in or Create an account to join the conversation.
- Nicholas Loggie
-
- Offline
- New Member
- Posts: 12
Please Log in or Create an account to join the conversation.
- raffaEl
-
- Offline
- New Member
- Posts: 1
This is wonderfull solution!
I've got two questions, how can we improve this:
1. When clicking on monts from earlier yeras (ex. 2012) tabs get back to 2013, the same when we're inside the article. How can I modify the code to maintain year selected from archive?
2. Can we extend this to show articles list below selected month? That would be perfect, exectly like Blogger archive works!
Best Regerds,
raffaEl
Please Log in or Create an account to join the conversation.
- Bruno Ferreira
-
- Offline
- New Member
- Posts: 1
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] K2 Tools archive module sort by year than month