Joomla 5 Mitteilung

Wir freuen uns mitteilen zu können, dass seit dem 29. Januar 2024 alle unsere Joomla Erweiterungen mit Joomla 5 kompatible sind.

Für alle die gerade noch von Joomla 3 auf 4 aktualisieren: Anleitungen für die Joomla 4 Migration gibt es hier:

Es gibt nun auch eine eigenständige Dokumentation für Visforms für Joomla 4 und für Visforms auf Joomla 5

Forum

Visforms Subscription Inhaber können in unserem Forum Fragen stellen. Bitte mit dem entsprechenden Benutzer anmelden.
Jeder kann lesend auf das Forum zugreifen.

Bitte stellen Sie nur 1 Frage pro Thema.

Wichtig Angaben für fast jede Frage:
V1: Welche Visforms-Version läuft?
V2: Welche Joomla-Version läuft?
V3: Welche PHP-Version läuft?

Aufgrund von Feiertagen und Urlaub ist bei Anfragen im Forum in der Zeit vom 20. Dezember 2024 bis zum 8.Januar 2025 mit verlängerten Antwortzeiten zu rechnen.

ISO Week Number

Mehr
1 Jahr 3 Wochen her #9899 von LittleCloud
ISO Week Number wurde erstellt von LittleCloud
Hi There, 

I have a form where I need to get the ISO Calendar Week number from a field that contains the current date. For example, if one of the field dates has the current date as November 27, 2023, then another number or calculation field would be pre-populated by calculating that it is week number 47 (of 52). Can your calculation field able to perform such a task? If not, is there any work-around to doing it, such as incorporating a JS snippet (see  date-fns.org/v2.16.1/docs/getWeek ). Having the field pre-populate with the correct calendar week would be preferable than to have the user do extra work to figure out which week we're on. 

Thanks.

Nelson

Mehr
1 Jahr 3 Wochen her - 1 Jahr 3 Wochen her #9902 von Administrator IV
Administrator IV antwortete auf ISO Week Number
Hello Neslon,

Here is a form with your example installed.
Form field 'birth date' is the date field for selecting a date.
Form field 'ISO Calendar Week' automatically displays the calendar week of the currently selected date according to ISO-8601 (weeks starting on Monday).

The unfilled form:
vi-solutions.de/forum-uploads/week-of-year-form_start.png

The form with a selected date and the automatically calculated calendar week:
vi-solutions.de/forum-uploads/week-of-ye...rm_date-selected.png

The form configuration, tab 'Frontend Webassets':
vi-solutions.de/forum-uploads/week-of-ye...rm-configuration.png

The function used in JavaScript comes from this website:
www.w3resource.com/javascript-exercises/...date-exercise-24.php

Your 'incorporating a JS snippet' is called 'Frontend Webassets' in Visforms:
docs.joomla-4.visforms.vi-solutions.de/e...-frontend-webassets/
All settings are made in the form:
docs.joomla-4.visforms.vi-solutions.de/e...are-made-in-the-form

A comment on your example.
Quote: 'November 27, 2023, that is week number 47'.
Unfortunately that is not correct.
November 27, 2023 is in week 48 according to ISO-8601.
Please also see here:
www.epochconverter.com/weeknumbers

The JavaScript code from the form configuration, tab 'Frontend Webassets':
Code:
jQuery(document).ready(function() {     console.log(' FEWA script loaded');     const dateFieldID   = '479'; // Visforms date field ID of field list     const numberFieldID = '555'; // Visforms number field ID of field list     jQuery(`#field${dateFieldID}`).on('change', function() {         let value = jQuery(this).val();         let parts =value.split('.');         const date = new Date(`${parts[2]}-${parts[1]}-${parts[0]}`);         jQuery(`#field${numberFieldID}`).val(getWeekISO8601(date));     });     function getWeekISO8601(dt) {         const tdt = new Date(dt.valueOf());         const dayn = (dt.getDay() + 6) % 7;         tdt.setDate(tdt.getDate() - dayn + 3);         const firstThursday = tdt.valueOf();         tdt.setMonth(0, 1);         if (tdt.getDay() !== 4) {             tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);         }         return 1 + Math.ceil((firstThursday - tdt) / 604800000);     } });

The following must be adapted to your form in the JavaScript code:
The Visforms field ID for the date field: const dateFieldID = '479';
The Visforms field ID for the week field: const numberFieldID = '555';

You can use text or number (as in the example) as the field type for the week field.

Kind regards, Ingmar

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).
Letzte Änderung: 1 Jahr 3 Wochen her von Administrator IV.

Mehr
1 Jahr 3 Wochen her #9903 von LittleCloud
LittleCloud antwortete auf ISO Week Number
Wow! Thank you so much Ingmar! Very well explained. I appreciate the details a lot, especially that I'm new to coding. I understand the "Frontend Webassets" much more now. Thank you.

Nelson

Moderatoren: Administrator AVAdministrator IV
Powered by Kunena Forum