Joomla K2 - How to order items by Extra Field Date - joomla

Me and a colleague are developing a website using joomla, we have ditched the joomla article component and replaced it with K2.
A part of the site's content , is posting (using K2 items) upcoming Live Events, such as an upcoming music concert, containing info about that event, images etc.
We want to find out if its possible to order these items, by the Date of the Event, or in other words how to order these items by the Extra Field : Date, of the item. K2 core only let's us order these items by Date Published or Date Created which is not what we need.
If anyone knows an easy way to overcome this obstacle it will be deeply appreciated!

we have been working on exactly the same events issue. K2 does not allow this, but we found a way of doing this in k2. The solution is an override of the template, but just one line is added.
Our events section is here vida latina events , there is 1 extra field "date". We wanted to order by this field (this solution would work for any other extra field too).
Solution
Create a menu item linking to an empty article.
Create a module k2 contents that selects from your k2 category, that appears on your new empty page
For "Order by", select "Title alphabetical" - we use this as we are going to hack it - so it needs to be an order you will not use for any other module
Open the file modules/mod_k2_content/helper.php
on line 195 find the code
case 'alpha' :
$orderby = 'i.title DESC';
break;
and replace with:
case 'alpha' :
$orderby = 'i.extra_fields DESC';
break;
This will work if you only have one extra field. If you have more than one extra field, you will have to modify the solution, but I think you get the general idea.
Hope this helps
Jeyjoo

I'm working on a similar project-making an event calendar using K2. I had the same question. What I am going to do is - for an event that is on Sept 22 2012, I will set the creation date at Sept 22 2011 (a year before). Then I will set K2 to order by "creation date" and set creation date to be hidden. This seems like a perfect solution...the only problem would be a leap year date (February 29) BUT you could set creation date to Feb 28 of the year before, and use the hours and minutes to get correct order that one day. I hope this makes sense.

Related

Google sheet adding a layer on top of a vlookup to make it conditional on a yes/no and a date

I would like to put in a basic toggle into a Google sheet.
Here is my reference table, It gets imported from another Google document so it's updated all the time.
I also have another google sheet that goes back to this lookup reference. It fills in the data if the date is less than today's date and matches the Date and the Source columns as a key.
I'd like to add another part in the Google sheet that says Include Today and you can type in the word "Yes"
If you type in Yes, I would like the yellow section, that uses the lookup_ref reference table, to include today's date, and otherwise include only days before today. In the example here, today is October 14, so if we type in "Yes" into this field, we need to have a value other than 0 for V15.
Okay, so you want to optionally include today's values in the formula. So you can conditionally add 1 day to today based on the value of "Include Today".
For example, if you add "Include Today" Yes/No value at cell "Z1", then you need to add IF(Z1="yes",1,0). So your formula can be
=IFERROR(IF(O15 < today() + IF(Z1="yes",1,0), vlookup(A15,lookup_ref,4,false), 0),0)

Data Studio Table Chart is not sorting correctly

I have a working chart of podcast episodes by download count in a query. That query is used to create a table chart in Data Studio. The file name formats are as follows: 2020/889-Jan-16-2020-DMP.mp3
Well Episode 1000 isn't showing at the top now in the sorting order. Because it thinks 1000 is less than 999. See table below:
2020/999-Jun-24-2020-DMP.mp3
2020/998-Jun-23-2020-DMP.mp3
2020/997-Jun-22-2020-DMP.mp3
2020/996-Jun-21-2020-DMP.mp3
2020/995-Jun-18-2020-DMP.mp3
2020/994-Jun-17-2020-DMP.mp3
2020/993-Jun-16-2020-DMP.mp3
continuing ...
2020/886-Jan-13-2019-DMP.mp3
2020/885-Jan-12-2019-DMP.mp3
2020/884-Jan-9-2019-DMP.mp3
2020/883-Jan-8-2019-DMP.mp3
2020/882-Jan-7-2019-DMP.mp3
2020/881-Jan-6-2019-DMP.mp3
2020/880-Jan-5-2019-DMP.mp3
2020/879-Jan-2-2019-DMP.mp3
2020/1001-Jun-30-2020-DMP.mp3 <-------Should be at the top of the table
2020/1000-Jun-29-2020-DMP.mp3 <-------Should be at the top of the table
2019/878-Dec-19-2019-DMP.mp3
2019/877-Dec-18-2019-DMP.mp3
2019/876-Dec-17-2019-DMP.mp3
Let me know if that makes sense...
1) REGEXP_EXTRACT
It can be achieved by adding the REGEXP_EXTRACT Calculated Field below as the Sort field and setting the order to Descending (The RegEx extracts the respective number component, for example 1001):
AVG(CAST(REGEXP_EXTRACT(Field, "^\\d+/(\\d+)-") AS NUMBER ) )
Google Data Studio Report and a GIF to elaborate:
2) Troubleshooting Calculated Fields (Invalid Formula)
Adding a section on general troubleshooting for Calculated Fields based on an Earlier Post on the Google Data Studio Forum:
Field Editing: Have a look at whether Field Editing is Enabled (Although it shouldn't affect creating Data Source Calculated fields);
Refresh: Refresh the Data Source Fields as well as a Fields in the Report;
Page Reload: Shortcut - F5;
Hard Page Reload: Shortcut - Ctrl + F5;
Chart-level Calculated Field: Double check whether using a Chart-level Calculated Field instead of a Data Source-level Calculated Field, resolves the issue.
I found that doing this worked too - sort date granularity by Year Week
Sort date granularity by Year Week

Dynamics 365, Entity View, format date field to "Month Year"

I am working on an entity view that displays billing records with associated date. This date field needs to be displayed as "Month - Year". Unfortunately, I am not able to find a way to format this date field outside of modifying the entity and even then, I only have the option for date only or date and time.
I have noticed that I can select the field and click on Change Properties. There I have "Web Resource" and Function Name. I have tried creating a web resource with a function that returns some data. Set everything up, saved and published. This function is not even found in dev tools. Only examples that I have for it are dealing with using this method for icons:https://www.c-sharpcorner.com/article/view-customization-with-javascript-in-dynamics-365/
In another example the suggestion is to use calculated fields, but this would cause me to lose date sorting and filtering on the form.
That view-based JavaScript seems to be to choose an icon. I'm not sure it would allow you to reformat actual data in the view. And if you're looking for assistance with trying to do that, you'd probably get more help if you posted the code.
Besides the JavaScript approach, you might want to think about creating a separate text field to hold the "Month - Year" value. Then you could use a workflow, plugin, or JavaScript to populate it when the datetime field changes.
One of the free workflow tool packages (Jason Lattimer's, Aiden Kaskela's, or Andrew Butenko's) probably has the ability to parse the date so you can format the month and year, and store the string in the separate field. This would be a no-code option.
Alternatively, you could write a plugin to reformat the datetime values and register it on the RetrieveMultiple message of the entity.
I'd probably go with a separate field and an off-the-shelf workflow utility to populate it.
There are several ways:
1. Setting->Administration->System Setting->Format->Customize,
2. http://prntscr.com/ph42nc,
3. or use on load with js to change date format more on this subject here: How to change date format in JavaScript

Dynamics CRM Marketing list dynamic date condition

I need to build a marketing list with date condition like so:
Month("End Date") = "This month" + 4
Basically, find records with End Date in 4 month
For example, if I pull the list on 6/12/17 - I will get all records with end date in Oct: 10/1/17, 10/2/17, etc
The closest I found is "Next X Month" but it also includes records within 3 month.
As an alternative - I'm exploring a path of creating workflow to update the "query" value of the marketing list record. Unfortunately, it's not possible to add Query field to the default form... this is getting very complex for a simple requirement.
Any ideas would be appreciated!
In the marketing list manage members, use "Add using Advanced Find" option and add all records with "Next 4 Month". Then use "Remove using Advanced Find" option and remove all records with "Next 3 Months".
Basically we can have a batch job every night, which will calculate the desired date or month filter for each contact record. Then fetchxml query for dynamic Marketing list can target this field.
Similarly rollup field can also be tried in contact.

Joomla article field date minimum limit

I am Building a Family site with Joomla 3.7.3 and are trying to add custom fields to the articles. I am e.g. adding the birthday of a Family member in a field. But, it seems like I cannot create a date before 1900-01-01. Do you know of a workaround for this and maybe why one would add this limit to a date field?
Note: I see that there is an option called: "minyear" in the documentation. It might solve the problem, but how do you use it?
Even though the datepicker popup only goes back to 1900, you can manually type in whatever date you want.
You can change the date format disabled by going to Language Overrides and changing the constant of DATE_FORMAT_LC4 to F d, Y or whatever format you want.
If you want to tinker with the datepicker functionality, I believe those files are in /media/system/js/

Resources