Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/15/2019 in all areas

  1. Using the brand new "multiple methods" hook feature in PW 3.0.137 you could save the average stars value to a decimal (or float) field every time a comment is approved/disapproved/updated/deleted. Then you can find or sort pages by the field more efficiently. The hook below assumes a comments field named "comments" and a decimal field named "decimal": $wire->addHookAfter('FieldtypeComments::commentApproved, FieldtypeComments::commentUnapproved, FieldtypeComments::commentDeleted, FieldtypeComments::updateComment', function(HookEvent $event) { /* @var Page $page */ $page = $event->arguments(0); /* @var Field $field */ $field = $event->arguments(1); if($field->name !== 'comments') return; if($page->template->hasField('decimal')) { // Save the average star rating for comments with approved or featured status $page->setAndSave('decimal', $page->comments->find("status=1|2")->stars(true)); } }); P.S. You'd do a one-off API operation to save the average stars value for all your existing comments to get things set up initially.
    3 points
  2. When I installed Processwire for the first time, I noticed that Admin sessions were not lasting for a long time and it was very common to be logged out. Reading this forum I found useful information, but I could not solve this issue. I tried to modify site/config.php adding $config->sessionExpireSeconds with different values, but without success (for your awareness sessionExpireSeconds default value is 86400 seconds, ie 1 day .. so quite enough!). OK, I had no time to go deeper, so I kept doing what I had to do ... being happily logged out … time to time. Few weeks later while studying Session.php in wire/core/ I got the hint (please read the commented text) which helped me to understand how to solve it: if(ini_get('session.save_handler') == 'files') { if(ini_get('session.gc_probability') == 0) { // Some debian distros replace PHP's gc without fully implementing it, // which results in broken garbage collection if the save_path is set. // As a result, we avoid setting the save_path when this is detected. } else { ini_set("session.save_path", rtrim($this->config->paths->sessions, '/')); } } Uh! Yes, my VPS uses Debian 9 ! So I quickly did a test: echo ini_get('session.gc_probability'); echo ini_get('session.gc_divisor'); echo ini_get('session.gc_maxlifetime'); The session.gc_maxlifetime was rightly set to 86400, but session.gc_probability was 0 ! As you can easily get from Session.php routine, if probability is 0 bye bye PHP's session garbage collection and of course PW will not set the save_path. But why probability is set to 0 ?? This is due to the fact Debian/Ubuntu Linux overrides standard PHP’s session garbage collection by setting session.gc_probability to 0. As a consequence PHP’s standard session garbage collection will never run. Instead Debian/Ubuntu sets a specific Cron job for garbage collection with a duration of 1440 seconds, ie 24 minutes. This determines the max session duration. If you try to change session.gc_maxlifetime through $config->sessionExpireSeconds=86400 or ini_set('session.gc_maxlifetime', 86400) it will have no effect and sessions will be deleted at intervals of 24 minutes (or within 54 minutes). The Cron job garbage collection duration is defined at php.ini level, and runtime changes to session.gc_maxlifetime will not affect the Cron job timeout. Uh! Of course the simplest solution would be to change session.gc_maxlifetime in php.ini. However sometimes this is not possible (shared hosting). Another point to consider is that this change may affect multiple applications running on your server. Instead of modifying php.ini, personally I preferred to enable PHP's session garbage collection locally for Processwire only. Majority of the code is already written in PW Session.php, we have just to take benefit of it. Let's go step by step. Let's open site/config.php and do the following modifications (I choose to implement 14400 seconds session time, ie 4 hours): /** * Reduce inactivity timeout (original 86400 = 1 day) * How many seconds of inactivity before session expires */ $config->sessionExpireSeconds = 14400; /** * Enable Session Garbage Collection * Garbage Collection is disabled in Debian as default (probability set to zero) * Enable session garbage collection with a 1% chance of running on each session_start(); * Chance calculated as gc_probability/gc_divisor * Session path is defined inside wire/core/Session.php and points to site/assets/sessions * Thanks to this modification session now takes into account gc_maxlifetime set in config */ ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 100); Do not forget to lock site/config.php after modifying it. Here it is! We are done! After we have set gc_maxlifetime (through sessionExpireSeconds), enabled the garbage collection (gc_probability=1), and set its intervention probability (gc_divisor=100 ie 1% chance), we can rely on Session.php where the a session path (session_save_path()) is defined, and session is started (session_start()). In the development session of our browser let's look for our session cookie: if you go to site/assets/sessions you will find your corresponding session: Please note that during development phase, likely having little traffic, the number of sessions may grow and they will not be deleted. This depends from the 1% chance of deletion. If you want to test garbage collection is properly working or just to make sure sessions files are regularly cleaned during development, you can decrease gc_divisor to a lower rate(10=>10% ... 2=>50%). Do not forget to reestablish gc_divisor = 100 when moving to production. I hope some can find that tutorial useful in the future ... and may save several log outs!
    2 points
  3. Hey ho! Sorry for late reply. All answers helped a lot! By knowing where to find the image sizer logs I could see that memory exceeded as horst suspected. I've tried the imagemagick module before but even if I checked everything I could it did not seem to work. Just before asking for help here and with my hoster. I found the mistake with rubber duck debugging ;)) -> The images where already generated (broken), so processwire did serve the broken images. After getting rid of them, the imagemagick module does a wonderful and ligthing fast job by recreating them. All fine! grazie mille! Toni
    1 point
  4. For a front-end search form? One strategy I often use is concatenating the selector one input field at a time. Just make sure your add your validation. Something like this: $selector = ''; if($place = sanitizer()->selectorValue($input->post->place)) { $input->whitelist('place', $place); $selector .= ", place%=$place"; } if($input->post->doctor) { $input->whitelist('doctor', $input->post->doctor); if($input->post->doctor == '1') { $selector .= ", name=jim"; } elseif($input->post->doctor == '2') { $selector .= ", name=jon"; } elseif($input->post->doctor == '3') { $selector .= ", name=jake"; } } $limit = 12; $template = doctor; $parent = doctors; $selector .= ", sort=sort, limit=$limit"; $selector = "template=$template, parent=$parent" . $selector; $results = pages()->find->($selector);
    1 point
  5. 1 point
  6. Offtopic, but have you (@zeka) had a look at RockFinder and RockGrid? And the upcoming RockFinder2 and RockTabulator? ?
    1 point
  7. Hm... For whatever reason the halt() method is protected and can therefore only be called from within the class or derived ones. Passing $this to the function does not work and I don't know of any solution other than using die() or exit() in this case. Or just let the function return false and halt outside in that case: function foo() { if(...) return false; echo 'foo bar'; } if(foo() === false) return $this->halt(); echo 'something more';
    1 point
  8. Glad it works, thanks for the feedback! This fix will be integrated in the next release, so you'll be able to update safely. Cheers
    1 point
  9. Hi @sz-ligatur Looks like you've found a bug! The relevant code is here: https://github.com/wanze/SeoMaestro/blob/master/src/MetaSeoData.php#L30-L35 It looks like these lines do not grab the field's value in the current language. Can you try to change the code like this: // Old if ($field->get('meta_title_format')) { $value = str_replace('{meta_title}', $value, $field->get('meta_title_format')); } // New $metaTitleFormat = $field->get('meta_title_format' . $this->getCurrentLanguageId()) ?: $field->get('meta_title_format'); if ($metaTitleFormat) { $value = str_replace('{meta_title}', $value, $metaTitleFormat); } Not tested and written in the browser, but maybe it works ? Cheers
    1 point
  10. A Ferrari 360 is way more elegant than a VW Golf V but still... you can't move more than 4 boxes (4x 12 bottles) of beer with it. So... if you feel fancy, you can pay for it - as in hosting prices. Actually Python is supported pretty good in most of the hosting environments I know. And compared to cars it's kind of a Porsche Cayenne and you can move 10 boxes of beer with it and still can go 230km/h if you wanted to.
    1 point
  11. Definitely, I would recommend PW. In my case, the client didn't like the tree structure of pages, so I had to create separate Process modules for managing news, tags, banners, categories. I have found that it's much easier to control permissions and workflow via custom modules.
    1 point
  12. https://www.baumrock.com/portfolio/individuelles-crm-und-controlling-tool/ I'm happy to share my biggest and most interesting ProcessWire project so far with you It's a 100% custom office-management solution that helps my client to keep track of all their contacts, projects and finance/controlling stuff. Conception was done back in 2016 and the software is productive since begin of this year. My client is very happy with the result and so am I. Some technical insights: Everything is done inside the PW Admin. I'm using the Reno Theme with some custom colors. In the beginning I was not sure if I should stay with the pw admin or build my own admin-framework but now I'm VERY happy that I went with PW Almost all of my custom Process Pages use my RockDatatables module - there are still some limitations but without it, this project would not have been possible For the charts I used Google Charts and chartjs - both play well together with the datatables and make it possible to display filtered data instantly: also my handsontable module was created for this project to have a nice and quick option for matrix data inputs: Lister and ListerPro were no options as i needed much more flexibility regarding data presentation (like colorization, filtering and building sums of selected rows): invoices are highly customisable as well and easy to create. PDFs are created by php and mPDF by the way: all data is dummy data populated via my Module RockDummyData have a nice weekend everybody
    1 point
  13. Hi all. First of all, I want to thank you all who blessed us with this great CMS. I have done 20+ sites with this and I'm very happy. I love the API. In case anyone is interested in using Discord to chat and talk about ProcessWire, I made server for us. Discord is a free voice and text chat app designed specifically for gaming, but it's very good for our kind of communities too. Chatting is similar to IRC, voice is similar to TeamSpeak or Mumble, and there will be coming new features like video chatting. Also chance to use notifications when someone talking in a specific channel, but the server's default is only notified when mentioned. There can be multiple channels in one server; general, help, devtalk, security, specific languages. All can be public or accessed by only for a certain role. And if you're not there, let's say for five days, you can still search or read things what people have talked since you were there last time (if mod did not purge that channel). Windows and Mac clients are very good ones, but Linux is still in beta. And of course, there is webchat too. More information about Discord can be found here: https://discordapp.com/ Of course, all the ProcessWire developers can get moderator access to the server. Forums are, of course, very good place to discuss things (and I have found many answers from here), but that is not real time and getting the answers you need can take a lot of time here. People want to get their answers faster, right now, so that’s why Discord can be a very good way to grow our community. Think about it. Invite link to server
    1 point
  14. Can you compare my settings to yours, because in my case it works well. I have my JS custom file located in the folder "ckeditor". Path to the JS-file entered in the input: mystyles:/site/templates/ckeditor/mystyles.js and in the mystyles.js I have fe UIKit styles like these: CKEDITOR.stylesSet.add( 'mystyles', [ { name: 'Inline Code', element: 'code' }, { name: 'Inline Quotation', element: 'q' }, { name: 'Bild links', element: 'img', attributes: { 'class': 'align_left' } }, { name: 'Bild rechts', element: 'img', attributes: { 'class': 'align_right' } }, { name: 'Bild zentriert', element: 'img', attributes: { 'class': 'align_center' } }, { name: 'Small', element: 'small' }, { name: 'Text durchstreichen', element: 'del' }, { name: 'Inserted Text', element: 'ins' }, { name: 'Cited Work', element: 'cite' }, { name: 'Highlight', element: 'mark' }, { name: 'Einfügen', element: 'ins' }, { name: 'Sample', element: 'samp' }, /* Uikit headlines */ { name: 'unterstrichen', element: 'h3', attributes: { 'class': 'uk-heading-divider' } }, { name: 'Linie in der Mitte', element: 'h', attributes: { 'class': 'uk-heading-line' } }, { name: 'Kugel am Anfang', element: 'h', attributes: { 'class': 'uk-heading-bullet' } }, /* Uikit paragraphs */ { name: 'Kleine Schrift', element: 'p', attributes: { 'class': 'uk-text-small' } }, { name: 'Große Schrift', element: 'p', attributes: { 'class': 'uk-text-large' } }, { name: 'Nur Kleinbuchstaben', element: 'p', attributes: { 'class': 'uk-text-lowercase' } }, { name: 'Nur Großbuchstaben', element: 'p', attributes: { 'class': 'uk-text-uppercase' } }, { name: 'Erster Buchstabe groß', element: 'p', attributes: { 'class': 'uk-text-capitalize' } }, { name: 'Farbe: gedämpft', element: 'p', attributes: { 'class': 'uk-text-muted' } }, { name: 'Farbe: Primär', element: 'p', attributes: { 'class': 'uk-text-primary' } }, { name: 'Farbe: Erfolg', element: 'p', attributes: { 'class': 'uk-text-success' } }, { name: 'Farbe: Warnung', element: 'p', attributes: { 'class': 'uk-text-warning' } }, { name: 'Farbe: Gefahr', element: 'p', attributes: { 'class': 'uk-text-danger' } }, /* ul classes */ { name: 'Liste mit Kugel', element: 'ul', attributes: { 'class': 'uk-list uk-list-bullet'}}, { name: 'Liste mit Linie', element: 'ul', attributes: { 'class': 'uk-list uk-list-divide'}} ] ); Here is a screen shot of the custom styles dropdown: So in my case I didnt find it difficult to add styles
    1 point
  15. I was being nice - the man behind the counter even said he thought I was very nice as he dialed the police.
    1 point
×
×
  • Create New...