Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by nurkka

  1. @adrian @Robin S I didn't know about these features yet – many thanks!
  2. Hi all, my proposal is, that every module should have an "active" checkbox, which allows to quickly deactivate it, instead of being forced to uninstall/reinstall it. Like AdminOnSteroids had and TracyDebugger has. Best regards!
  3. Thanks for testing. I was using the latest stable version of ProcessWire (3.0.229) and upgraded now to the latest dev version (3.0.239). The issue seems to be gone (for now), i.e. I get the same data on saving the page – no matter if I change something in the page editor or not.
  4. Here is an example of the template file: $json_data = []; foreach ($page->contentblocks as $cb) { // "contentblocks" is a repeatermatrix field $json_data_block = $cb->render(); // this returns an actual json array array_push($json_data, $json_data_block); } header('Content-Type: application/json'); echo json_encode($json_data); And here is an examle of a repeatermatrix field template file: $json_data = []; $json_data["headline"] = $page->text; // "text" is a multilanguage text field $json_data["text"] = $page->body; // "body" is a multilanguage textarea/tinymce field return $json_data; // no json_encode needed Returning JSON data from the template did not work, because the $page->render() method threw an error ("strlen(): Argument #1 ($string) must be of type string, array given"). So I had to convert the JSON data to a string in the template and convert it back in the module. The advantage is, that one can view the page in the browser and check the JSON output.
  5. Hello everyone, I use ProcessWire with multilangage support (5 languages) to provide a shop with content as JSON files. To match the specifications regarding the structure of those JSON files, I wrote a module that exports the files on page save. It renders a page and outputs the language content in different JSON files, within different folders. The module hooks into the Pages::saved hook. As soon as a page is saved in the admin area, the module loops over the languages, renders the page content in each language and writes a JSON file for each language. The following phenomenon now occurs: If one edits individual fields of the page in the admin area and then saves it, the JSON files are output correctly. If one saves the page again – without having changed a field on the page – $page->render() does not return the text content of the multilanguage fields, but objects with the text content of all languages. These are e.g. LanguagesPageFieldValue objects or ComboLanguagesValue objects. I believe this must have something to do with the trackChanges behaviour. ProcessWire tracks the changes that have been made to fields. If no changes have been detected, the behaviour appears to be different when saving the page and with $page->render within the Pages::saved hook. Here is the code (simplified) I am using: <?php namespace ProcessWire; class ExportAsJson extends WireData implements Module { public function init() { $this->addHookAfter('Pages::saved', $this, 'hookPageSaved', ['priority' => 200]); } protected function hookPageSaved(HookEvent $event) { $page = $event->arguments(0); // get the saved page // save current settings $saved_lang = $this->wire->user->language; $saved_user = $this->wire->user; $saved_output_formatting = $page->of(); // set current user to guest user $this->wire->users->setCurrentUser($this->wire->users->getGuestUser()); $page->of(true); $json_data = []; foreach ($this->wire->languages as $l) { $lang_name = $l->name; // set current language for rendering the page $this->wire->user->language = $l; // get rendered json data as string $markup = $page->render(); $json_data[$lang_name] = json_decode($markup); } // restore saved settings $page->of($saved_output_formatting); $this->wire->users->setCurrentUser($saved_user); $this->wire->user->language = $saved_lang; // write the JSON data to separate files on the remote shop server $this->writeJsonToSftpAsSeparateFiles($page, $json_data); } } The correct result in JSON would be like this: [ { "featureHeadline": "Lorem ipsum dolor" } ] But when I save the page without changing a field beforehand, I get this: [ { "featureHeadline": {} } ] Does anyone have an idea how to fix this behaviour? Thanks and best regards!
  6. Hi @Chris-PW I removed the javascript block for meta-shift-s and ctrl-s. After that, pressing ctrl-s in TinyMCE worked perfectly. Tested in Chrome/Windows11 and Firefox/Windows11, and via BrowserStack, also in Safari 17.3/MacOS Sonoma. Additionally, I removed the timeout in UIkit.notification(...) in QuickSave.js, because my pages have so many fields and languages that saving the page takes several seconds. And because the page is reloaded anyway, in my case it was better to simply leave the notification until the page reloads.
  7. @Chris-PW Many thanks for contributing this module. That was really a much needed missing feature. I am using the module with Chrome (Iron) under Windows 11, where in TinyMCE fields, pressing CTRL-S saved the page twice. It seems, that Chrome/Windows reacts also to "meta-s". I then went to quicksavetinymce.js and commented out the block for "ctrl+s". Now, pressing CTRL-S within a TinyMCE field saves the page only once. Thanks again for this great module! P.S.: This also works with Firefox/Windows
  8. Hi all! Is there a way to add comments and documentation directly in the admin area, e.g. above the page editor? Field descriptions and notes are not sufficient in some cases, when one wants to document more complex things or explain something more detailed. I know that one can add a custom admin page, but I am searching for a way to document things directly in the pages where the editor users are working. Thanks in advance for any tips!
  9. Hi @kongondo, today I tried to upgrade a ProcessWire website from PW 3.0.210 to 3.0.229. After that, when trying to access pages in the backend, which contain MediaManager fields, the following error occured: ProcessWire\WireException Item 'type' set to ProcessWire\Pagefiles is not an allowed type search File: /html/website/wire/core/WireArray.php:458 448: * 449: * @param int|string $key Key of item to set. 450: * @param int|string|array|object|Wire $value Item value to set. 451: * @throws WireException If given an item not compatible with this WireArray. 452: * @return $this 453: * 454: */ 455: public function set($key, $value) { 456: 457: if(!$this->isValidItem($value)) { 458: throw new WireException("Item '$key' set to " . get_class($this) . " is not an allowed type"); 459: } 460: if(!$this->isValidKey($key)) { 461: throw new WireException("Key '$key' is not an allowed key for " . get_class($this)); 462: } To verify that this error was caused by Media Manager, I renamed the directory "MediaManager" in the modules folder. Then, the error disappeared. I had to downgrade ProcessWire for now, but the website has to be updated sooner or later, as other modules and parts of the site depend on it. Do you have any hints what I can do to avoid this error or is there a bugfix release of MediaManager?
  10. @bernhard Thanks again for your help! I finally managed to also get SSH keys to work under Windows with WSL2 and with DDEV installed in Windows, so that now I am able to use RockShell how it's meant to be 🙂 The key point, why I struggled with the ssh keys was, because I had put the key files in the ~/.ssh folder on the WSL2-Linux installation. But as I am using the Windows version of DDEV and using the command line from the windows side, the ssh keys must be placed in C:\Users\YourNameHere\.ssh After that, one can simply use this command, which will copy the ssh keys into one's web container: ddev auth ssh Then one can use e.g. the following RockShell command like so: ddev php RockShell/rock db:pull * * * * * And here is how to add a shell function under Windows, when using PowerShell 5: # test, if the PowerShell profile, where you can store custom shell functions, already exists Test-Path $PROFILE # if not, create the PowerShell profile New-Item -path $PROFILE -type file -force # Open the profile file with an editor. it's located here: # Path: C:\Users\YourNameHere\Documents\WindowsPowerShell # Name: Microsoft.PowerShell_profile.ps1 # Add the shell function to the profile file: function rockshell { param( [string]$Command ) ddev exec php RockShell/rock $Command } After that, save the file, restart PowerShell, and now it is possible to use RockShell like so: rockshell db:pull Many thanks @bernhard for creating RockShell, and for your help!
  11. @bernhard @dotnetic Thanks for your replies! In my current project I followed your advice and now work with a local ddev, a staging server and a live server. Currently I still have no automated scripts yet, but working with the command line (wsl2, ddev and ssh) works really good. Also, I mostly got rid of large ftp uploads, using rsync. Working with that tools feels better every day 🙂 But when trying to copy the local ddev website to the staging server, I got stuck. I exported the database with ddev php RockShell/rock db:dump, uploaded it via rsync. connected via SSH and tried php RockShell/rock db:restore on the server. But as the ProcessWire database tables were not present at this point yet, RockShell/rock returned an error message. So I had to fall back to Adminer to import the SQL file. What would be the right way to copy a locally developed website to a staging server with RockShell?
  12. I have also tried RockMigrations, but I still don't use it as standard. I'll take another look at RockMigrations, thank you very much! Do I understand you correctly that when further developing a website that is already live, only templates, fields and modules can be updated? For example, when I create a new page type, I not only create a new template and new fields, but also one or more pages and fill their fields with content. Can this newly created content also be transferred to the production environment with RockMigrations? If so, that would mean that you have to create not only the new fields, but also all the new content in php code, and not via the ProcessWire backend, right?
  13. Firstly, many thanks for the brilliant input regarding DDEV. I'm finally using DDEV for local development and it's really super fast. My latest project is now 100% finished locally and I saved a lot of waiting time. @bernhard I understood from your posts that you have a staging version and a production version of your projects on the remote server. - What is the benefit of a remote staging version for a single developer? Wouldn't it be easier to omit the staging server? - What I still can't deal with is the following problem: If I put the website live now, my customer and their team will start editing content, creating pages, etc. in the ProcessWire backend. In addition, there will be contact form entries and blog comments from end users, i.e. ultimately user-generated content, which will also end up in the ProcessWire database. The website is to be continuously developed, i.e. I will be adding fields, modules and templates over the coming weeks and months. I understood, you would clone the database to local and continue working on the website locally, and later copy everything back to remote. But then I would overwrite the changes my client and the users have made in the meantime. How do you deal with this problem? Are you developing the site locally, and once deployed to production, do you work on the remote server? I tried to connect to a server database remotely, and it is super slow. Before DDEV, I had the classic setup with uploading every change to the remote server via FTP and refreshing the browser manually. I do not really want to go back to that ... Appreciating any help ... !
  14. Does anyone know how one can add a style to the TinyMCE styles dropdown, which applies a css class to several HTML-Elements at once? I managed to do it with JSON like so in the "Default setting overrides JSON text" field: { "style_formats": [ { "title": "Styles", "items": [ { "title": "Center", "selector": "p,h1,h2,h3,h4,h5,h6", "classes": "text-center" } ] } ] } But how is the syntax for achieving the same within the field "Custom style formats CSS"? Or is this simply not possible (yet)?
  15. I noticed that, in my case, I cannot have more than one CKEditor field with mystyles.js on the same template, except within repeaters or repeater matrix fields. The solution was to configure mystyles.js only for the first textarea CKEditor field and to use the feature "Inherit settings from another CKE field" for the others. Then the custom styles work as expected.
  16. Hi kongondo, I just watched the video and it looks very good! I already sent some suggestions a while ago, but I wanted to repeat an important one: I have some projects where the clients have lots of PDFs with very long detailed technical names. I assume the PDFs won't have thumbnails in Media Manager, so it would be very good if one could switch the view to a really compact list view, where the filenames would not be cropped. Perhaps in this list view also some other meta data could be shown, like filesize etc. Also I would add that the filenames or image titles as shown in the video are cropped in a way it makes them nearly unreadable. So I am wondering if you could consider an option to not crop those titles or filenames at all?
  17. Hi @kongondo It would be nice to have a full text search, which would always be visible. If this is not possible, it would be nice, if the filter would be always open, so one can start typing immediately and previously set filter values would be visible right away. Also a more compact view for pdf documents would be great, because the current grid and list view both require a lot of space if one has some hundred pdfs in the library. In a past project I added the pdf filenames to the grid view by modifiying some javascript files, to have a more compact view with the filenames visible. Perhaps, pdf icons could be a lot smaller or omitted at all in the document view. The UI elements could be smaller and information like how many times an image was used, filesize, etc. could be hidden and made visible with a toggle button, so everything would take up less space and more image and document items would fit on the screen.
  18. Hi @kongondo First of all thank you for the awesome plugin! It would be really awesome if the selection would run through an interface with a folder structure. And it would be perfect if one could define per template in which folder the selection would start. An example: Assuming we have a folder "Employee photos" and a folder "Customers" (or a lot more folders and subfolders 😉 ), then it would be perfect if one could give the input field the information that the image selection on employee detail pages starts in the folder "Employee photos". That would be much easier for the clients/editors to work with. And without a folder structure, it would be great if one could define per template with which category or tag the input field starts, i.e. to have a ore-defined filter setting per template.
  19. Hi everybody, in another post some weeks ago @ryan mentioned that the language-alternate fields were deprecated and that he doesn't expect many will ever use them. As I am using language-alternate fields for image-fields and url-fields, I wonder if there is any other, non-deprecated solution? Thanks and best regards
  20. You could use the redirects plugin: https://processwire.com/modules/process-redirects/ It also allows to import the redirects as comma separated list, where each line contains one redirect.
  21. Hi everybody, is it possible to hide a page in the default language of a multilanguage website? The page’s settings tab doesn't seem to allow it, because there is no checkbox next to the default language’s url and it can’t be left empty. For the time being I implemented a checkbox "hide in default language", and if checked, the page outputs a wire404(); But is there any native way to do it? Thanks and best regards
  22. Hi everybody, some time ago I implemented a blog in ProcessWire with the comments function. The comments have avatar images which were displayed based on the commentators email address. To manage the avatar images and some other data, I added custom fields to the user template. This used to work perfectly, but today I noticed that the avatar images were missing. $user = users()->find("email=mail@example.com"); echo $user->first()->get('name'); // works perfectly echo $user->first()->get('user_display_image'); // doesn't work anymore UPDATE: I just found out, how to get the field value again. One has to check the option »Make field value accessible from API even if not viewable«. Screenshot: I assume, the functionality must have been changed sometime between 2019 and 2021. With the above setting it works again.
  23. Thanks BitPoet, the following code worked: function custom_debug_if () { return true; // simply for test reasons } $config->debugIf = 'ProcessWire\\custom_debug_if'; Using if(wireIsCallable($debugIf)) instead of if(is_callable($debugIf)) in ProcessWire.php made no difference. Thanks again and best regards!
  24. Hi everybody, while testing $config->debugIf, I noticed, that it wouldn't work with custom functions. Example /site/config.php: function custom_debug_if () { return true; // simply for test reasons } $config->debugIf = 'custom_debug_if'; This doesn't work because the if(is_callable($debugIf)) in ProcessWire.php returns false. The debugIf-documentation says: * 2) Your own callable function name (i.e. "debug_mode") in /site/config.php that returns * true or false for debug mode; How is it possible to use this feature? Thanks and best regards!
  25. Hi! The feature Automatic Page Name Format of the PageTable field has stopped working after a ProcessWire upgrade. I was using the following configuration string, which worked perfectly before: Y-m-d_H-i-s_\d\o\w\n\l\o\a\d The config string was interpreted as PHP date format, where you can escape characters to mark them as non-date-formatting characters. The PHP docs state the following: PageTable generated the page names like the following example: 2017-03-13_12-17-24_download But after a ProcessWire upgrade (I assume it must have been version 3.0.123) the page names are now generated as follows: y-m-d-h-i-s-d-o-w-n-l-o-a-d The config field settings description now states: So, I tried several other configurations, like: Y-m-d:H-i-s \d\o\w\n\l\o\a\d Which renders the date part correctly, but the string "download" is unfortunately also processed as a date format. I assume the configuration setting is somehow filtered by ProcessWire before it is passed to the php date function. This was not the case in older versions of ProcessWire. Sorry, I haven't the time to test with which version the behaviour changed. The feature stopped working somewhere in january 2019, so I assume it must have been the upgrade to ProcessWire 3.0.123. Has anyone similar issues with the Automatic Page Name Format in PageTable?
  • Create New...