Articles filtered by year menu items

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
aefferen
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 18, 2007 8:12 pm

Articles filtered by year menu items

Post by aefferen » Thu Jul 15, 2021 9:45 pm

Hi,

I have this website with all Lego technic sets listed; http://www.rabbitdesign.nl/index.php/20 ... 2-09-30-07. Fun to browse.
Next to that the same list by year: http://www.rabbitdesign.nl/index.php/20 ... ts-by-year.
I am at the latest Joomla 3.9.28.
What I want to create is a menu structure:
1970
------1977
------1978
1980
------1981
------1982
etc..
Each time when you select a year-menu item only the articles with creation date of that year will be shown.
I can't get this to work. I would expect this can be done with vanilla joomla, seems to me basic functionality.

I created modules with dynamic set and date ranges but didn't show anything and what ever menu-item-type I select a date range filter is not available.
In this context archiving is not applicable, however if someone knows how to 'misuse' it I am all ears.

After browsing this forum for this topic without result I decided to post my question.
Thanks for any hints, upfront

embedNZ
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Jul 27, 2021 1:52 am

Re: Articles filtered by year menu items

Post by embedNZ » Fri Jul 30, 2021 5:41 am

I would suggest just creating your menu items for your years manually. link all items to the same page and just apply a filter on your main items array before out putting the data.

like mysite.com/year?y=1970, mysite.com/year?y=1977.

just loop through before outputting and unset anything you don't need. ie:

Code: Select all

<?php foreach ($this->items as $i => $article) : ?>
	<?php if ($article->date > $_GET['y']) : ?>
	
	//either use 
	continue;
	
	//or unset and loop through output again.
	unset($this->items[$i]);
	<?php endif;?>
<?php endforeach; ?>
Ideally this should allow you to only display the years you want?


Locked

Return to “General Questions/New to Joomla! 3.x”