Skip to main content

#142 How to changer day order and create a default view

Posted in ‘Calendar Filter’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information (available for public)

PHP version
8.2

Latest post by b2z on Saturday, 15 February 2025 21:58 EET

Semaphore

Hi,

We are currently trying to create an agenda view

The module works fine but :

  • after filtering by month the order is not by day
  • we need to create a default view on this page and obviously order by day (a custom field in our case) : can we create an url that we can use for creating this view.

In our main idea we thought using this https://www.netzsinn.de/netzsinn-custom-fields-filter for filerting the initial view but as expected there is a conflict with the your module.

Have you some idea on how we can create a filtered blog view based on custom field and using your module. This is a "classic" case we will have to create in multiple project.

Thanks for your help

b2z

Hi Nicolas,

As far as I understand you want to have a feature like "Order a Blog Category by a Custom Field", right? Probably this plugin will help you https://www.dionysopoulos.me/software-tools/sort-by-field.html

Kind regards,

Dmitrijs

Semaphore

Hi,

Thanks for quick answer.

We already use this plugin but like all these plugins they conflict with your module because they use the articlemodel.

And they don't solve the other issue : after filtering  on a month the article are not order by the date custom field used for the filtering.

The scenario is :

  1. A blog view for events using a customFieldDate (short name: cFD) for ordering
  2. When we open the agenda page we need to order the blog view by the cFD.
    • If we use a orderby plugin it conflict with the module: can we to avoid that issue (I have some knowledge abut php but not this far) ?
    • your module which generate some url with parameters don't provide a url order by cFD and based a current date : can you add url's parameters we can use in menulink for ordering by the cFD and based of the current date (filter by month and year : you already do that but we can't hardcode the month and year in the url ^^ )
  3. after displaying all the events articles, if we filter on a day or a month, the article are not ordered by this cFD : can you add a setting like "order by years" but "Order by the selected date"

b2z

I understand. You are right, there will be a conflict because of the same Articles model override. Unfortunately it is not possible to solve.

So you need a feature for ordering by custom field. For that you need:

1. URL parameter like this:

?cfilter=1&filter[bydate]=custom&filter[field]=1&filter[order]=asc&filter[month]=2&filter[year]=2025&filter[day]=11

2. Module parameter:

Field Ordering: Ascending / Descending.

And you also need a feature to put into the menu an URL without year, month and day like this:

?cfilter=1&filter[bydate]=custom&filter[field]=1&filter[order]=desc

And this URL should filter by the current year, month and day.

Is it correct?

Kind regards,

Dmitrijs

Semaphore

It sound like a plan :D

With this your module will do the complete job but it will require some docs for users creating the menu with URL without year, month and day

Thanks for your understanding.

b2z

What docs? :)

This a standard way - create a hidden menu item for you view (like /agenda) and then create a menu item of type URL with the link like this:

agenda?cfilter=1&filter[bydate]=custom&filter[field]=1&filter[order]=desc

Kind regards,

Dmitrijs

Semaphore

Of course I know how to create the asked url ^^ I was thinking for your others customers ;-)

So you think it's doable ?

b2z

Hello!

Features are implemented. I can share a development version of the module with you and you will be able to test it.

Please drop us a line to support@norrnext.com to get it.

Kind regards,

Dmitrijs

b2z

Forgot to mention, the URL should look like this:

?cfilter=1&filter[bydate]=custom&filter[field]=1&filter[field_order]=desc

This will filter articles with the current year and month by custom field with ID=1 and articles will be ordered by this custom field in the descending direction. Use asc to change the direction to ascending.

Kind regards,

Dmitrijs

Semaphore

Youhou !!!! So quick ! We just sent email, can't wait to test it and give you some feedback

 

Semaphore

As said by email : the url trick is working fine, it a life savior, but the filter[field_order]=desc is missing when we use the year/month/day filters. If we add it manually after a filtering : it works fine. A simple miss I think ;-)

Next feature : a date range :D (not that easy ^^)

b2z

Have you resaved the module settings? Only after that ordering will appear in the filtering.

Sorry, but range won't be possible to implement. If you wish, you can try to modify the code, it is open source :)

Kind regards,

Dmitrijs 

Semaphore

Yes I have but still no order url paramerters on filytering.

There it is my settings (we can see the new setting) : https://imgur.com/K2KHfhn.png

My default url : /agenda?cfilter=1&filter[bydate]=custom&filter[field]=21&filter[field_order]=asc

and after clicking on "march" for filtering : /agenda?cfilter=1&filter[bydate]=custom&filter[field]=21&filter[month]=3&filter[year]=2025

b2z

Strange, as I do not have such issue on my test website. May be calendar.js file has been cached. Please try to clean the browser cache or do ctrl+F5 several times (if you are on Windows) on the page. Also you can check if the javascript file has been updated - there should be filter[field_order] piece of code.

Kind regards,

Dmitrijs

Semaphore

Hmmm mafter many mnay test there is my resultsts :

  • calendar.js is okay
  • all depends of the layout selected !
    • Calendar : give nothing, no calendar diplayed, nothing just the module tilte
    • Default : The one we use, no error message but but no filer_order
    • ui, bootstrap etc : error message on the  intial url : Warning: Undefined array key "year" in modules/mod_calendarfilter/tmpl/list-uikit.php on line 43  wich iI uspposed remated to the lacj of the parameter in the URL
      BUT the filter order is working on month !
  • other weird issue : I uninstall the module and resinstall. even if article link is set to no it  display a link (but with a wrong route) of the previous insall : maybe a unsinstall issue wivch don't clean all sql ?

b2z

I send you a version with a fix for Undefined array key "year".

Regarding layouts - there is no layout calendar in our module. It is something custom you have.

Regarding article link - I do not have any issue with it. If it is set to no, it is not displayed. Please check, do you have any overrides?

And as I said before - there is no issue with field_order for me for all layouts the module have.

Kind regards,

Dmitrijs

Semaphore

The calendar view came from you own dev zip ^^ : https://imgur.com/fa8R2dH.png

It's not in the last zip you send me ;-)

And indeed the min version didnn't have the order.

The last sended version if ok for all these issues.

One new appear (sorryyyy). If I set the URL menu item as Articles Links, it display this : https://xxxxxxxx/?Itemid=1490

b2z

Regarding incorrect link - it is a standard way to create URL link in Joomla to a menu item:

<?php echo Route::_('index.php?Itemid=' . $itemId); ?>

It seems that Joomla cannot handle correctly the menu item of type URL. Probably an override is the only way to display the link you want in that case.

Kind regards,

Dmitrijs

Semaphore

But it works correctly in a previous version ! How you change the way this link is coded ?

We can easily add this with an override but if you module is oftently used as our way (the with URL as "start url") the "All articles" links have to handle the URL.

b2z

There was no change. It was always the same  code to display the link. You can ensure by yourself, just compare the code in the previous version with this version.

Kind regards,

Dmitrijs

Support information

Support hours: You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+3), but not limited. Our staff is pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days.


Our time: / Your time:

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. We also ask you to remove temporary credentials at your site after the problem is resolved. Thank you.

Support of free extensions is not provided on this forum. Please submit your questions or report issues via Github tracker. See link on the product page.