Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by Stefanowitsch

  1. 10 hours ago, bernhard said:


    Cars are fetched automatically from an austrian cardealer API and converted into ProcessWire pages with a custom filter page: https://www.autohaus-bendel.at/fahrzeuge/


    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.

  2. On 6/9/2022 at 10:19 AM, Liam88 said:


    I have a separate sort dropdown and filter section. This is very similar to the processwire demo - https://demo.processwire.com/search/?sort=parent.name

    I also have the same "issue" if you would call it that where i can sort or I can filter, but I can not do both. This is because the url changes.

    So a sort URL may look like:


    and a filter like:


    I'm looking to be able to sort and filter. So if I change the sort, it won't remove the current filter and vice versa.

    I have the sort dropdown running off one bit of JS and the filter on another with examples of both below:

    I might get into the same "issue" in a project I am working on. If I find a solution I will inform you here 🙂

  3. 5 minutes ago, AndZyk said:

    Hello @Stefanowitsch,

    you get the unformatted value of the datetime field probably because output formatting is turned off when bootstraping ProcessWire.

    You could try to temporarily turn it on and then turn it off again:

    $page->of(true); // Turn output formatting on
    echo $page->date; // Should be formatted
    $page->of(false);  // Turn output formatting off again

    But I would rather just format the date. 😉

    Regards, Andreas

    Thanks! But this does not work unfortunately... 

    However formatting the date like this was the workaround for me:

    date("d.m.Y", $termin->startdatum)
    • Like 1
  4. 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.

  5. 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).

  6. 32 minutes ago, zoeck said:

    I think this has to do with your time zone 😉

    Do you have the Language Support module installed?
    If yes, go to Administration -> Languages and select the appropriate language

    Then edit the "wire--modules--languagesupport--languagesupport-module.json" file and set your locale in "C" (example: de_DE.UTF-8)


    Can you post a timestamp as an example?

    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

  7. 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).


    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?

  8. 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',
    $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:


    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' );


    • Like 3
  9. 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

    • Like 1
  10. 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 */

    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).

    • Like 4
  11. 1 hour ago, olafgleba said:

    Thx. The latest ProField Repeater Matrix has the option (input tab) to define the method for adding items. When you choose Images you get the overlay. By default, the image of the matrix type having the same name and be placed along with the the type file location (for example: /site/templates/fields/modules_page/matrix_type.php => site/templates/fields/modules_page/matrix_type.svg). Preparing a good looking Image is just up to you then 😉

    Ah okay. I do not use the ProField Modules. That's a really cool feature, though.

    • Like 1
  12. Most of the time its the smallest things that cause the biggest problems when going "live" with a site 🙂

    9 minutes ago, wishbone said:

    thank you!! when I understood it's not a matter of the pw-install, I searched again - and I don't believe how easy it was: the database name was casus sensitive. I had the prefix in capitals: DB...

    how many hours!

    learnt also that it's ok to just copy all the files from local to remote without new install

    thx again

    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

    • Like 1
  13. 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

    • Like 2
  14. 2 hours ago, tcnet said:

    There are not a single ERROR MESSAGE in your post! These are Warnings and Notices which you get when you run ProcessWire in debug mode.

    And why they not appear? Because your ProcessWire DON'T run in debug mode.

    Sorry about that! Yes these messages are not error messages. But when you open a page and see a few hundred warnings you can get a bit nervous 🙂

    On my live site I don't get these messages at all, despite the debug mode set to off. So only my local environment causes the issue when there is no IP address assigned to my virtual host.

    2 hours ago, tcnet said:

    I made a change in line 389. It seems that getenv('REMOTE_ADDR') doesn't work with local IP addresses. Please upgrade to version 1.1.6.

    Thanks for the fast help! I tried to upgrade via the PW upgrades module but this time I got a real error message:

    Modules: Error upgrading module (ProcessPageViewStat): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS usr int(10) unsigned' at line 1


  15. Hello!

    I installed the module and it works fine for me.

    But my local dev environment I get a ton of error messages - when not logged in -

    Warning: unpack(): Type V: not enough input, need 4, have 0 in /Users/sthumann/Sites/kibis/site/modules/ProcessPageViewStat/func/IP2Location.php on line 1013

    This message repeats itself a hundred times, then at the end there are these two lines:

    Notice: Trying to access array offset on value of type bool in /Users/sthumann/Sites/kibis/site/modules/ProcessPageViewStat/ProcessPageViewStat.module on line 407
    Notice: Trying to access array offset on value of type bool in /Users/sthumann/Sites/kibis/site/modules/ProcessPageViewStat/ProcessPageViewStat.module on line 408

    In the modules settings I disabled all options. These error messages only appear when:

    - not logged in (on local dev environment)
    - when my local host has not an IP address assigned to it. I am using MAMP Pro on Mac...

    On the live site these messages never appear.

    I guess the that the IP2Location throws those errors when there is "no ip address" to find. 

    So my question is if there is a way to detect if the page runs on a local test system to disable the tracking functions in those cases?

  16. Okay this solution is a little bit over-the-top for me. But the IntersectionObserver Function looks quite interesting. I've never heard of that before.
    In fact all my hand made "is element in viewport?" solutions were always kind of tricky to pull off.

  17. On 2/9/2022 at 12:59 PM, heldercervantes said:

    Natasha Marques is a desserts chef and chocolatier from Brazil with an international carreer. Now established in my hometown Porto, she's about to open a shop and already shipping her premium line of sweets and desserts.

    The website is my usual combo of PW with StencilJS frontend with a content blocks approach. Minimal stack of modules: SeoMaestro, WireMailSmtp, and my own block selector module which is a hacked version of FieldSelectFile.

    The site is only in portuguese, but have a look anyway:

    I really like the clean look and the choice of color. The pink hue really gives a warm touch. And I absolutely like sites with big colorful images.

    What plugin was used for the image translation effects? Looks super smooth.

  • Create New...