Jump to content

olafgleba

Members
  • Posts

    124
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by olafgleba

  1. Will submit to it on weekend.
  2. @horst @howdytom Hi, same here. I empty the variants list. Original formats gets deleted, webp files remains in the asset folder. In my case, wether the image field is placed in a RepeaterMatrix (v5, latest) or is a single PW Field. It makes no difference. This is a big drawback. In my current project there were a buch of files corrupted on creation (webp). Which causes strange behaviour in google chrome. Inspected this a couple of hours,- until i found out the webp files won't get deleted physically form the asset folder. And so never being recreated. Deleting them manually solves the problem. But iterating through all assets folders by hand i cannot afford. Get rid off them with a script seems the way to go... While debugging i tried out all possible execution markup and calls as i assumed somethings wrong with my integration/code. But this was not the case. All scenarios (s. below) works fine since it turned out the only problem were the remaining webp files. PW 3.0.192 dev, GD lib image sizer Engine. @horst If there is anything i can do to help further exploring the behaviour, please let me know. Excerpt: With $config->useWebP = true; , lazysizes <?php $options = array( 'upscale' => false, 'cropping' => 'center' ); $page_image_palm = $page->image_head->size(480, 640, $options); ?> <picture> <source class="" media="(max-width: 480px)" data-srcset="<?= $page_image_palm->url; ?>" alt=""> //... <img class=" lazyload" data-srcset="<?= $page_image_palm->url; ?>" alt=""> </picture> Excerpt: With $config->useWebP = false; / Markup with default API call like in https://processwire.com/blog/posts/webp-images-on-an-existing-site/ <picture> <source class="" srcset="<?= $page_image_palm->webp->url; ?>" type="image/webp"> <img class="" src="<?= $page_image_palm->url; ?>" alt=""> </picture> And some other calls in between...
  3. @horst Your assumptions were all right. Argh, it happened quite more than once that i simply forgot about that. Thank you very much for your brief and clear explanation. @bernhard @Robin S Big thanks also for your advice and details.
  4. Hi, depending on the status of a set checkbox (set_create_vcard) i generate VCF files on page save (admin). For this i have a hook (s. below) placed in admin.php. Everything behaves like it should. But when i try to integrate a image in the vcard i get the following message/error on page save (Returned data is not a image comes from the exception class of the VCard lib). ProcessPageEdit: Returned data is not an image. I am asking this question here in the PW Forum (and not on the github board of the lib), because integrating the (essentially) similiar code in a regular template file (e.g. outside the hook) works flawlessly (with the same images accepted, e.g do not trigger any error). I am rather a newbie when it comes to hooks. So its likely that i miss something. Any hints much appreciated, Olaf <?php // file: admin.php // get vcard lib (composer module) on top use JeroenDesloovere\VCard\VCard; /** * Admin template just loads the admin application controller, * and admin is just an application built on top of ProcessWire. * * This demonstrates how you can use ProcessWire as a front-end * to another application. * * Feel free to hook admin-specific functionality from this file, * but remember to leave the require() statement below at the end. * */ $wire->addHookBefore('Pages::saveReady', function($event){ $page = $event->arguments(0); if($page->hasField("set_create_vcard")) { if($page->set_create_vcard == 1) { $page->set_create_vcard = 0; // define vcard $vcard = new VCard(); // define variables $fullname = $page->combo_contact->name; // add personal data $vcard->addName($fullname); /* ... some other allocations ... */ // WHERE IT BREAKS... if($page->image_contact) { $vcard->addPhoto($page->image_contact->filename); } $vcard->setSavePath($this->wire('config')->paths->root.'process/public/vcard'); $vcard->save(); $this->message('VCF Datei für den Kontakt wurde erstellt'); } } }); // Do not touch... require($config->paths->adminTemplates . 'controller.php');
  5. Hi @Zeka, many thanks for your hint! Helped me to get going. My first guess was right,- missed something obvious ?. Too avoid the mistake i made, this might help other forum members eventually: As long as an file (which is used by a javascript ajax call) is not accessible to the processwire core (e.g. is a dedicated page derived from a template at least), such things as core translation etc. are not available in those files. My approach here was to create a template, create a page from this template (with the code of my former `contacts-flatproducts.php`, s. OP) and took this page as my reference within the form action attribute.
  6. Hi, here is a task thats new to me. And obviously i overlook some basics. So maybe someone is so kind to give me some advice on this... I have a page whichs collects some contact boxes straight away on page load. It is a multilanguage Site (default is in German, the screenshots shows the english version). The results are wrapped in a form, because the user is able to narrow the resulting contacts by a page reference language switcher (values are part of every contact entry)*. This is done with a javascript ajax request to avoid page reloads. TL;DR: While everything is fine on page load, as soon as i select a country to get the related contact boxes by a ajax call, the static translated strings within the target PHP file are not recognized, e.g. their translation fails. I assume i simply miss some basics here what and when things get parsed when doing such asynchron call. *) The language switcher values has nothing to do with the choosen user language. And for the brave ones... On Page load: The highlighted areas are static translated strings (s. below). All is fine on page load (whatever current user language). If the user selects a country within the language switcher, the form in submitted per JS, do a ajax call and query the results by the giving value of the select option (more details s. below). The result is valid and looks like this (here i narrowed the result to contacts related to germany): BUT: As you can see, the static translation strings (s. highlighted areas) are not translated (e.g. use the default site language). To give a brief overview how its done, here some excerpt screens. Form tag with action target: Javascript: And here is the processing target PHP file (excerpt): contacts-flatproducts.php Many thanks in advance, Olaf
  7. Meanwhile i found the way to deal with my approach for translations. Possibly it helps others, so i post it here. Tl;dr: I have a function to enable translation of static template strings. This allows me to reference a _strings.php file as site translation file in the PW Backend. To apply this to the SearchEngine Module, you have to edit some configuration settings before rendering. $searchEngine = $modules->get('SearchEngine'); $config->SearchEngine = [ 'render_args' => [ 'strings' => [ 'form_label' => _t('Suche', 'search'), 'form_input_placeholder' => _t('Ihr Suchbegriff...', 'search'), 'form_submit' => _t('Suche', 'search'), 'results_heading' => _t('Suchergebnisse', 'search'), 'results_summary_one' => _t('Ein Ergebnis für "%s":', 'search'), 'results_summary_many' => _t('%2$d Ergebnisse für "%1$s":', 'search'), 'results_summary_none' => _t('Keine Ergebnisse für "%s".', 'search'), 'errors_heading' => _t('Hm, ihre Suchanfrage konnte nicht ausgeführt werden', 'search'), 'error_query_missing' => _t('Bitte tragen Sie einen Suchbegriff in das Eingabefeld ein', 'search'), 'error_query_too_short' => _t('Bitte verwenden sie mindestens %d Zeichen für den Suchbegriff.', 'search'), ] ] ] <?= $searchEngine->renderForm(); ?> <?= $searchEngine->renderResults(); ?> === Approach to translate: _func.php /** * This function enables the translation of static template strings. * All translations are done in `_strings.php`. More info within the * comments of `_strings.php`. * * @param string $text text to translate * @param string $context Context to allow doubles * @param string $textdomain Point static textdomain * @return function Function for gettext parser */ function _t($text, $context = 'Generic', $textdomain = '/site/templates/_strings.php') { return _x($text, $context, $textdomain); } _strings.php /** * Static translated template strings to use project wide * in any templates. This spares us defining page fields * for every piece of code that doesn't have to be editable * within the admin interface. The function doesn't need to * execute with PHP, so we wrap it in a comment leaving * the code only visible to the language parser. * * Relies on function `_t` (s. `_func.php`) * * Usage: * 1. Define string in markup, e.g. "_t('<string>', '<context>')" * 2. Insert string in `_strings.php`, e.g. "_x('<string>', '<context>')"; * both without the surrounding double quotes. This is just to avoid * this comment is parsed. * 3. Choose the language you like to translate the default language strings * 4. Under (possibly still empty) "Site Translation Files" click on "Translate File" to get * a list of translatable files. Choose the `_strings.php` and click send/save. You'll * see the translatable string phrases. */ /*! _x('Suche', 'search') _x('Ihr Suchbegriff...', 'search') _x('Suchergebnisse', 'search') _x('Ein Ergebnis für "%s":', 'search') _x('%2$d Ergebnisse für "%1$s":', 'search') _x('Keine Ergebnisse für "%s".', 'search') _x('Bitte tragen Sie einen Suchbegriff in das Eingabefeld ein.', 'search') _x('Bitte verwenden sie mindestens %d Zeichen für den Suchbegriff.', 'search') */
  8. First, teppo, thanks a lot for this module! It is really a great timesaver. SearchEngine v. 0.30.5, PW 3.0.192 dev. I struggle a bit with text translation feature (Labels, Placeholder a.s.o.). As i need to translate those text in several languages, initializing SearchEngine with $user->$language conditions statically is rather not an option. I see the getDefaultStrings() function, but have no clue how to benefit from it. Maybe i overlook some docs. It would be very kind, if you or someone else could give me a brief overview how to set this up. Currently i simply render SE straight out of the box (with some $config->SearchEngine = [...] tweaks before it). Many thanks in advance, Olaf
  9. Thx @BillH I did that shortly after i sent my post. And there it was,- each of both related entries had a single whitespace before the string. Solved. Sorry for not posting this more in time.
  10. Hi, simple task, simple Question. I have a (quit large) result list with a alpabetic sorting on given titles only. $results = $pages->find("... sort=job_titel"); Funnily enough the output looks like this (on first page): So two entries obviously don't want to get sorted ? (beside those two entries all is sorted well) Any idea how that is possible? Checked the entries,- no weird characters or whitespace/LF s.o. in field job_titel Thanks for any hint, cheers, Olaf - ProcessWire 3.0.148
  11. First thanks for your effort building this module. The hreflang for the default language (de) is always empty within the sitemap, e.g. is not populated with the given ISO Code (de) from the module options, s. screenshots. But even though i don't set an ISO Code in the module options at all, i don't get a false hreflang="home" (something like that), but a empty attribute string also. Hopefully i plain doing it wrong. Maybe some someone have a hint for me... Thanks in advance.
  12. FYI, i got in touch with the hosting support. It turned out that my first suspicion was kind of right. The PHP version on the staging environment was actually not 7.0.33 (as shown in the hosting backend) but a old 5.6.x. And that causes the problem. Switching to PHP 7.x.x solves it.
  13. @elabx Yes, it does fail whatever length the strings has. On whatever pages. Pointing to mod_security is maybe helpful. I dig into this. I remember having some issues some time ago also (no related to this topic). Thanks for you suggestion!
  14. Hi, maybe kind of related to https://processwire.com/talk/topic/13286-image-description-not-saving/ but with other environment bits. While adding a new page/edit a existing page containing a image field, the image itself gets stored into the database but strangely the entered description does not. More strangely this only happens on my staging server. Within my local dev environment all is fine. And beside of this particular problem, all parts of the PW instance works fine. On both environments (s. below). First suspicion was the varying PHP/mysl versions of the local <-> staging environment. But, there are many working projects with the identical setting (s. below). And i never encounter this problem so far. No error/log/console output. It just fails to get stored. Local Environment: PHP 7.4.6, mysql 5.7.29, PW 3.0.148 Staging Environment*: PHP 7.0.33, maria DB 10.1.46, PW 3.0.148 Maybe someone has a hint what to try? Thanks in advance. *) I cannot change the staging server php/mysql settings because its part of a shared hosting account.
  15. That gives me the expected result (just like the output of a field with the default `datetime` Fieldtype). echo $return->getUnformatted('programm_date_advanced') // e.g. `1562233140`
  16. First, thanks for your effort making this extension! Environment: DatetimeAdvanced v1.0.4, PW 3.0.148, PHP 7.4.6, mysql 5.7., Timezone ist set. While accessing subfields as selectors within a $pages-find() works fine, i am having trouble using subfields within PageArray results. Definitely i miss something here. Maybe i should stop working for today, but meanwhile someone maybe have a hint what i am doing wrong... Thx, Olaf <?php foreach($results as $result) { // Directly access gives me "Notice: Trying to get property 'year' of non-object" echo $result->programm_date_advanced->year; // strftime shorthand gives me "Fatal error: Uncaught Error: Call to a member function strftime() on string" echo $result->programm_date_advanced->strftime('%Y'); // Using strftime plain gives me "Notice: A non well formed numeric value encountered" echo strftime('%Y', $result->programm_date_advanced); // Using strftime unformatted gives me "Warning: strftime() expects parameter 2 to be int, object given" echo strftime('%Y', $result->getUnformatted('programm_date_advanced')); // Plain output is o.k. echo $result->programm_date_advanced; // e.g. 10.07.2020 } ?>
  17. I absolutely agree. Currently the synchronisation is in development and testing. The database (or better said, the distributors API) only provides a very narrow set of interrogations. And has some strange data field types also (e.g. row modified is delivered, but internaly stored as a string type in a unusal format). So the create/delete of pages every import is just for testing purposes. If all is set and stable (and i can rely on the DB modified field), your approach is definitely the way to go. The questions (page ID limitation? Reset...) came up while testing. And i was curious about it ? Thx for you answer (also to @rick) Olaf
  18. Hi, in my current project i synchronize a thirdparty database (job advertisments) with my PW Instance every night. To reflect all possibly modified/added/deleted data sets it is mandatory to delete the whole set of related pages (page <=> database row) and rebuild all pages again every sync. So the page IDs increases constantly every run. I wonder if this could get me into trouble in long term. Is there any restriction of page ID values? That leads me to a related question. When i build pages through the PW API, is it possible/meaningful to maybe reallocate a (temporarily saved) ID of the deleted pages to the new build pages? To avoid the incrementation... Thanks for your thoughts in advance. Olaf
×
×
  • Create New...