Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. From past experience working with lat/lng coordinates, I suggest using a decimal field for these. Float fields only have a precision of 6 figures which is often not sufficient for a lat/lng value.
  3. Thanks, that is brilliant, multiple solutions for the same problem, built right into the core. PW just keeps giving. 🙂
  4. From $config->pagefileSecure https://processwire.com/api/ref/config/ - When used, files in /site/assets/files/ will be protected with the same access as the page. Routines files through a passthrough script. I haven't used this yet, but there might be a performance hit? I'm not sure how much though? From here Wanze writes:
  5. Sorry if it was covered, I haven't found an answer by searching in Google or on the forum. The client is an estate agency and they want that all images, pdf brochures etc… would disappear from their site when they unpublish or delete a property page. Is that only possible with a custom module that hooks into unpublish or delete? It seems that ProcessWire doesn't delete the folder associated with the page from assets/files/ automatically. Similarly, if the page is unpublished, file uploads are still publicly available with the direct url. As a result, Google would keep them in their index forever giving false results. I understand that images can be used elsewhere in the site so it makes sense to keep them available, however since images/files belong to a page, keeping their public status synced could also make sense. Any suggestion is welcome, maybe I haven't thought of something else.
  6. just a short update on this - i am stresstesting the PW way and i'm on the way yust with simple pages for now and see what comes up the road. made a crude script to get dummy data and created around 88k pages (DB are now 35MB) in very fast time on shared hosting...just for example to create 48 testrecords for every day (17260 pages - 2 records per hour) the scripts runs on in about 80 seconds...just for others that are search on create dummy content in a quick and dirty way i let my code here (if there are better ways - at least as a bad example..;) So far next things are to create a script that runs to build the averages of month, year for long term stats and then i will try how reporting and visualisation in an easy graph - works together with a DB that have around 90000 pages with just some integers and floats. I would first try how an easy to use chart library would work (https://gionkunz.github.io/chartist-js/index.html) Since this tools all use JSON data i think i could cache or better prepare this JSON strings for the charts and see how fast it performs...i'll report again. But this is an interesting experiment so far - i could choose how i spend my freetime in two really different worlds ->work on the backend with PW or solder and glue some things together on the hardware parts...before this project i was captured only on the web...;)
  7. I never had to deal with it myself, but check out Ryan's announcement.
  8. Then you asked the wrong question 😉 https://github.com/processwire/processwire/commit/f0cc6f1134e7c7ea5e99ed851862f612996de0c4
  9. Alright, I got it all sorted out and is working on my Unix & Windows hosts both locally and online. In case someone stumbles upon the same issue, here is what worked for me to have cyrillic languages and 1252 ones working fine: 1. Add the following code to _functions.php or other file that you use for your functions: /** * Convert date/time stamp from different characters to utf-8 */ function strf_time($format, $timestamp, $locale) { $date_str = strftime($format, $timestamp); if (strpos($locale, '1251') !== false) { return iconv('cp1251', 'utf-8', $date_str); } else { return $date_str; } } 2. Add this code to your head.inc (note that head.inc is included in all my templates) <?php // Check the user language name // Assign the language locale to $locale // Windows locale source: https://docs.moodle.org/dev/Table_of_locales switch($user->language->name) { // Default language is English case 'default': $locale = setlocale (LC_ALL, 'en_US.UTF-8', '-parent en_utf8 used-'); break; // Bulgarian language locale case 'bulgarian': $locale = setlocale (LC_ALL, 'bg_BG.utf8', 'Bulgarian_Bulgaria.1251'); break; // Russian language locale case 'russian': $locale = setlocale (LC_ALL, 'ru_RU.utf8', 'Russian_Russia.1251'); break; // French language locale case 'french': $locale = setlocale (LC_TIME, 'fr_CA.UTF-8', 'French_Canada.1252'); break; } ?> 3. Add a field to your templates that you would like the date to appear (set the field as DateTime) and no date/time format. In my scenario I called it 'date_created' 4. Assign the field to all templates where the custom date would be needed (in my scenario I assigned it to news-inner.php as I am grabbing some news pages to show on the main page). Note that I assigned the date field to the inner page of every news, but not to the parent or Home. 5. Add this code to your ready.php (if you don't have one create it at ../site/ready.php (where your config.php resign 😉 ). Inside of this file add the following hook (Thanks to @Edison for the code!) $wire->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments(0); if($page->hasField('date_created')) { $page->date_created = time(); } $event->arguments(0, $page); }); Please note that you need to replace 'date_created' with your custom date field (unless you follow steps 1x1). 6. In your markup where the MULTILANGUAGE ENABLED DATE is needed, use the following call: <?php echo strf_time("%d %B %Y", $l->date_created, $locale);?> Note: Feel free to change the date appearance format using PHP strftime function format Well, that is it, it works fine with me and showing all the languages properly now. If you would like to go further, some of the months that are having more than 3-4 letters in the abbreviation could have a dot after the name, however for this you should create an array with the shorter months and show the dot if it is not one of those or do some magic counting the letters of the month and if the result is higher than 3-4 to show it, but I did not go that way as it is working as the original markup 😉 Another issue I noticed is the Declination of the names of the months when displaying the date in Russian. I found a function that could heal that, however I hightly doubt I would need it. In case someone wants to play with it and adapt it for PW, here it is . Note, that the page is in Russian so you might need a translator or just read the code.
  10. @bernhard, thats what I did as well - but then I ran into trouble because I needed to access the same class from a different module (autoloaded as well). And then it became tricky because I don't know any way to control the order of autoloading 😉
  11. Well... the proper way would be to develop a fieldtype for that. Hacking this together with RockMarkup should be quite easy though: Just add a hidden inputfield for that purpose and populate it via JS whenever you update the value of the RockMarkup field. But you need to be careful with that approach because the value transmitted can be manipulated easily via browser devtools if you don't do server side validation!
  12. After a decent night sleep and my morning coffee I had some progress towards resolving my issue. While searching the Internet I found some useful pieces of code that I was able to put together to test my server setlocale. As it appears, it is all running properly with only one issue where for the cyrillic letters to appear properly, I needed to use iconv to convert them to UTF-8: The result of the script gave me this: mardi, juillet 23 вторник, Июль 23 вторник, юли 23 Tuesday, July 23 So now I will look for a way to use the function and apply it to all locales which should not affect the French/English date but will make the proper appearance of the cyrillic chars. Since I am on a Windows host, I had to use the Windows locales instead of the unix format, however running the code on my unix host returned the proper values as well so it seems like this solution is multiplatform one 😉
  13. Can I save a value for the custom markup field and output it's value on the edit page? Right now I have a calculation field whose value is calculated via JavaScript (depending on other fields). But now on page save, I want to save the calculated value to the field, so I can possibly output it in a Lister Pro column. Is this possible or can you make it possible? I think this would be a cool addition, because you can use the value on pages/listers, where the other dependend fields are not available.
  14. @valan You need to include both the autoloader from Composer and the ProcessWire bootstrap file, see Bootstrapping ProcessWire CMS. Assuming your autoloader lives under prj/vendor/autoload.php and the webroot with the ProcessWire installation under prj/web/, you can use the following at the top of your script: # prj/console/myscript.php <?php namespace ProcessWire; # include composer autoloader require __DIR__ . '/../vendor/autoload.php'; # bootstrap processwire require __DIR__ . '/../web/index.php'; ProcessWire will detect that it is being included in this way and automatically load all the API variables (and the functions API, if you are using that). Keep in mind that there will be no $page variable, as there is no HTTP request, so there is no current page.
  15. As always I work this out after 30 mins of trying, but always 2 mins after posting on a forum 😛 It was because the field type must be float. Funnily enough it works fine if it's Text, until you hit a negative number. I will leave this up for anyone who makes the same mistake as me.
  16. Hello I'm having an issue with filtering on a negative longitude value. My search filter looks like this (decimal places have been shortened for the example) $pages->find("template=skyscraper,longitude>=-0.1011,longitude<=0.0708,limit=10,sort=created"); Now lets say I have two pages, one has a longitude of 0.05, this one is found. Another has a longitude of -0.05, this one is not found, even though -0.05 is still greater than -0.1011...
  17. This is so awesome. Thank you @bernhard. Testing some things right now
  18. This is very cool. Much appreciated. @BitPoet Many thanks for your help. I ended up using your example and doing something like so.. $submissionsNames = array(); foreach ($page->submissions as $submission) { $name = ucwords(strtolower($submission->submissions_firstname . " " . $submission->submissions_lastname)); array_push($submissionsNames, $name); } $submissionsNames = array_count_values($submissionsNames); ksort($submissionsNames); arsort($submissionsNames); $submissionsNames = array_slice($submissionsNames, 0, 5); Let me know if you think I've missed a trick?
  19. Is there any reason why the CPU on my server would spike to above 70% and crashing (effectively) when entering a really long title for a page? The title in question is: Arts Facades: incorporating Duke of York’s Theatre, Harold Pinter Theatre, Phoenix Theatre, Fortune Theatre This has never happened to me before so any advice/debugging you can suggest would be appreciated.
  20. How to use both vendor libs and PW api in command line scripts? Assuming script is located here: prj/console/myscript.php
  21. Hello, I'm filling an image field from an 3th party API with the Processwire API. All goes well: 1. images are correctly uploaded in images field 2. the first image is correctly converted to a thumbnail and added to another field (thumbnails) 3. the script does not break But: i get a warning like (example) on almost every picture (twice, what is more strange): exif_read_data(17-1.600x0.jpg): File not supported What am I doing wrong? My code: $picture = $this->getImageAPI($pic['mediumUrl']['href'],$pic['rentalUnit']['objectID'].'-'.$pic['order']); if($picture != ''){ $pictel++; $p->oe_images->add('./'.$picture); $lastPic = $p->oe_images->last(); unlink('./'.$picture); $p->save(); } if($pictel == 1){ $thumbnail = $lastPic->size(600,0); $p->oe_thumbnails->add($thumbnail); $p->save(); }
  22. As simple as helpful, very appreciated! Thanks! For full compatibility of the module I would add in the settings "you admin path" because the default "processwire" may not always be used. And (as in my case) this leads to a page not found. Or alternatively in the readme file make it known.
  23. I think this would be a perfect use case for RockTabulator. Just get your external data, transform it into an array of objects and let RockTabulator do the rest. Finally add some links to a custom process module that shows an edit form (similar to a regular pw page edit) and save back that data to the original database. You can add all kinds of presentation helpers, colorizations, filters, sorting etc. or even charts (see https://processwire.com/talk/topic/17207-custom-office-management-crmcontrolling-software/ as an example). I'd be happy to assist you with that job - maybe you want to sponsor further development of RockTabulator, which is completely free and open sourced to the community... See also http://tabulator.info/examples/4.3
  24. You can assign your own API variables easily: // MyModule.module.php class foo { public function bar() { return 'works!'; } } class MyModule extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => 'MyModule', 'version' => '0.0.1', 'summary' => '...', 'autoload' => true, ]; } public function init() { $this->wire->set('foo', new foo()); } } You could also just save this instance to $config->foo $this->wire->config->foo = new foo();
  25. Thx teppo, please leave it as is 🙂 RockMarkup was released here:
  26. Your Welcome. It´s kind of my thing to try to keep things simple and understandable. Not just for myself but also so other could have use for my code. I will think about the GDPR issue. Have a nice day.
  1. Load more activity
  • Create New...