Jump to content

Stefanowitsch

Members
  • Posts

    137
  • Joined

  • Last visited

  • Days Won

    1

Stefanowitsch last won the day on February 12 2019

Stefanowitsch had the most liked content!

Contact Methods

  • Website URL
    https://www.thumann-media.de

Profile Information

  • Gender
    Male
  • Location
    Germany
  • Interests
    Web Design, Web Development, Music

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Stefanowitsch's Achievements

Sr. Member

Sr. Member (5/6)

60

Reputation

  1. I like the idea of having a cronjob for fetching data. I also used this technique in an actual project (that I will introduce here when its finished!) but there was no external API involved.
  2. Fascinating! Can you explain how you approached the API Data fetchig? Do you use a simple Ajax Request when filtering items or are you actually creating pages, populated with data and use those instead? I am always interested in methods to "feed" processwire from outside nowadays.
  3. I might get into the same "issue" in a project I am working on. If I find a solution I will inform you here 🙂
  4. Thanks! But this does not work unfortunately... However formatting the date like this was the workaround for me: date("d.m.Y", $termin->startdatum)
  5. I found the reason: https://www.php.net/manual/en/datetime.construct.php The $timezone parameter and the current timezone are ignored when the $datetime parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00). So thats why i get the wrong date when using this code here (my timezone gets ignored) <? echo IntlDateFormatter::formatObject( new DateTime('@' . strtotime($page->testdate)), "dd. MMM", 'de_DE' ); ?> Even when explicitly setting the timezone inside the DateTime object constructor it gets ignored.
  6. I am bootstrapping processwire in a php file for cronjob purposes. Everything works fine, I can output all the data from fields that I like. What confuses me: I have a datetime field. When displaying the field value in the bootstrapped file, I only get the timestamp of the selected date. When displaying the same field value on a page inside of processwire the field value is a formatted date. Can somebody explain to me why this is the case and to get around this (without date formatting).
  7. My config.php looks like this: $config->timezone = 'Europe/Berlin'; setlocale(LC_ALL, 'de_DE.utf8', 'de_DE'); I edited the json file in the Backend (with: de_DE.UTF-8). The timestamp looks like this: 1654898400 When examining this timestamp I get both dates: GMT: Friday, 10. June 2022 22:00:00 Your time zone: Samstag, 11. Juni 2022 00:00:00 GMT+02:00 DST It seems that I just ignored that fact that there are two dates shown (always look at the first one). My $page->testdate field outputs the date like this: 11.06.2022 So this outputs the right date (11. Juni): <?= strftime("%e. %B", strtotime($page->testdate)); ?> My problem is that this is deprecated in the future and the new way to do this looks like this: <? echo IntlDateFormatter::formatObject( new DateTime($page->testdate), "dd. MMM", 'de_DE'); ?> This also outputs 11. Juni (correct) But when using the timestamp I get the wrong date: <? echo IntlDateFormatter::formatObject( new DateTime('@' . strtotime($page->testdate)), "dd. MMM", 'de_DE' ); ?> This outputs 10. Juni
  8. I was upgrading some date formatting code lines in my projects and noticed a strange behaviour. I have a date field in the backend which is a classic processwire datetime field. In this field I can set - for example - an event date. For date selecting I am using the HTML5 Datepicker option in the field settings. Besides that I changed none of the fields settings at all. To display this date in the frontend all i do is: echo §page->event_date; However - I need to format this date in multiple ways throughout the whole site. So I need a unix timestamp (for localization of the date). strtotime($page->event_date); When I check the timestamp that comes out - it is always exactly 1 day before the date that was set in the date field. So when selecting "08.06.22" in the date field, the timestamp says "07.06.22" When I format the date -based on the timestamp- to make it human-readable again I can confirm that the new date is one day in the past... How is this possible?
  9. So i tried the other way around and formatted a date using the IntlDateFormatter. This thread helped me find my way: https://stackoverflow.com/questions/71874030/local-language-without-strftime-deprecated-but-with-date So imagine we want to output "today" like this (formatted for german) Mittwoch 8 Juni 2022 This was the old way to to it: echo strftime('%A %e %B %Y', strtotime('now')); Since this will be deprecated in PHP 8.1 and removed in PHP 9 now we have to make use of this instead: $fmt = new IntlDateFormatter('de_DE', IntlDateFormatter::FULL, IntlDateFormatter::FULL ); $fmt->setPattern('EEEE d LLLL yyyy'); echo $fmt->format(strtotime("now")); The only thing that freaked my out about this was the weird formatting pattern. At first sight it makes no sense (to me), but the ICU documentation offers a big list of available options for formatting the date in any way you could imagine: https://unicode-org.github.io/icu/userguide/format_parse/datetime/ If you are looking for a "one liner solution" then this seems to be the right way (https://stackoverflow.com/questions/12038558/php-timestamp-into-datetime) echo IntlDateFormatter::formatObject( new DateTime('@' . strtotime("now")), "EEEE d LLLL yyyy", 'de_DE' ); EDIT: Beware that timezone settings get ignored when you work with timestamps. This might get you into some trouble. My solution was to format the timestamp into a date string: echo IntlDateFormatter::formatObject( new DateTime(date("d.m.Y", $timestamp)), "EEEE d LLLL yyyy", 'de_DE' );
  10. I have no take on this (yet!) but since I am using the strftime function a lot I better get used to a solution for the future. The library you postet here https://github.com/alphp/strftime looks promising enough, the "old" strftime code needs to be altered just with the locale and it works good for me: <?= strftime('%e. %B', strtotime('now'), 'de_DE'); ?> The "offical" solution seems to use the IntlDateFormatter::format, but I find the usage is nowhere as straight forward as with strftime... https://www.php.net/manual/en/intldateformatter.format.php
  11. I was in the need for using this module together with background images too - but in the "classic" way without any components. I am using the famous Lazysizes JS Plugin for lazyloading the images. To create responsive background images with the PageImageSouce module I also included the lazysizes bgset extension So the code in my template file looks like this: <div class="img-title-wrapper lazyload" data-sizes="auto" data-bgset="<?php echo $image->size($imgFormat)->srcset() ?>"> /* your content */ </div> The wrapper element then gets it's height either via CSS (height: 100vh for a big introduction title image) or through the elements inside the container. Adjust the background image styles to your needs (e.g. background-size:cover).
  12. Ah okay. I do not use the ProField Modules. That's a really cool feature, though.
  13. Really cool design! I love the content module solution. I build something like that my own by using nested repeater fields... but can you tell me how you realized that good looking "Select type to add..." popup?
  14. Most of the time its the smallest things that cause the biggest problems when going "live" with a site 🙂 That is the usual way I do it (and I think most of developers do): 1. Export your local database 2. Create a new (empty) database on your live server and import the database there 3. Upload all project data from your local directory to the live server via FTP 4. Adjust the config files for the new database connection 5. Testing with debug mode enabled
  15. That is a classic error message that I get all the time: The Database connection cant be established. Mostly because I forgot one of the things: - Do you have a variable in your config to switch between two development environments (local/live)? So that you are still trying to use your local database settings on your live site? - Do you already have a working PW installation on the remote server? Try checking the config values against the config that refuses the connection
×
×
  • Create New...