Jump to content

olafgleba

Members
  • Posts

    104
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by olafgleba

  1. Thank you @ryan for clarifying this (i am sure this is explained somehere in the docs already, sorry...). I only have one $config->httpHosts array, e.g. multiple hosts. What i haven't considered: www.foo.bar is not the same as foo.bar. As i only defined foo.bar so far, but the site points to www.foo.bar, PW grabs the first array entry. Which is/was 127.0.0.1... Probably i missed that, because on all my other sites i tend to point everything to foo.bar, as i find it a bit strange to prefix regular addresses with the subdomain www for no technical reason.
  2. Hi, i hardly dare to ask (because surely i miss something obviously and it sounds a bit silly)... I transfer the local installation to the live environment. Frontend works fine, all admin links/buttons (like edit, settings tab etc.pp) also (e.g. prepends the live host root correctly). Except the view button (either in the page list or while in page edit mode) references to the/a localhost root instead of the real live host. Instead of https://www.host.tld/<path-to-page>/ i get https://127.0.0.1/<path-to-page>/ when hovering over the "view" button/link. This is confusing. Can't remember that i have to tweak anything in former projects. Just to confirm the database is sober, i queried the database,- there are no results for 127.0.0.1. So possibly is has something to do with the config or/and htaccess(?). But i can't find any false or missing input here, too. At least in comparison to many former projects on different hosts. Setup: PW 3.0.200, mysql 5.6, PHP 7.2.23 (stable) Any hints? Thx in advance.
  3. @Nick Belane Hi, fixed it but haven't found the origin of the issue. I just downloaded the latest PW (3.0.184 by the time) and replaced the wire directory, index.php and htaccess by hand. But as the current master meanwhile is 3.0.200, try to repeat the upgrade steps. Maybe there is no issue with this particular upgrade. Even though, you should be save to replace the mentioned dirs/files by hand (Nonetheless i recommend backing up all relevant folders).
  4. @teppo I completely agree. Thank you for your important addition. In situations where the search section is not a essential part of the UX of a site/project (with only low budget for this part), it is possibly o.k. to use just one approach. Still combining client- and server validation is to prefer in most cases.
  5. @bernhard Brilliant stuff, thx. I have to dig into Tracy soon (installed, but yet not fully explored).
  6. @Jan Romero Many thx for your reply. The missing d made the difference ;-). With Pages::saved all works fine. Either with After or Before.
  7. Hi, a question of a hook newbie... Probably a simple one, but nonetheless i don't get it after reading the docs and playing around. While in admin i do something with some page fields before saving a page (here: generating vcards). If the page already exists (e.g. edit the page), its straight forward: $wire->addHookBefore('Pages::saveReady', function($event){ $page = $event->arguments(0); // do something with some $page fields... }); But i forgot to handle the case when a page is added. This naturally this leads to a ProcessPageAdd: New page '/path/to/page' must be saved before files can be accessed from it For my understanding, i somehow must differ between Pages::added and Pages::save (or Pages::saveReady) and/or combine the two respectively. Anyway, i assume this may not quite right, so i am running out of ideas. Maybe someone could give me some advice how this should be done. Thx in advance!
  8. Hi, haven't seen this before: Upgrading a 3.0.98 installation breaks after second step (database backup, skip backup), s. screen below. State: Master is downloaded, Database backup done, folders are created. Modul Upgrades => last current version (1.1), cleared all possible caches twice. Any ideas? Thx in advance.
  9. Just as an addition to my post above. Maybe someone benefits from it... In a multilanguage environment the HTML5 validation prevents controll over the output on search input errors (example: when the search string is too short). It skips translated strings and always gets populated depending on the browser language settings. To disable the HTML5 validation, you must enhance the template render args for the form with the attribute novalidate. $config->SearchEngine = [ 'render_args' => [ 'templates' => [ 'form' => '<form id="{form_id}" class="{classes.form}" action="{form_action}" role="search" novalidate>%s</form>', ], ], ] With that, errors are displayed within the regular HTML Elements (which respects translated strings). I don't see any drawbacks so far. See also the comment from @teppo below!
  10. @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...
  11. @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.
  12. 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');
  13. 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.
  14. 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
  15. 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') */
  16. 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
  17. 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.
  18. 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
  19. 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.
  20. 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.
  21. @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!
  22. 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.
  23. 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`
  24. 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 } ?>
×
×
  • Create New...