-
Posts
1,489 -
Joined
-
Last visited
-
Days Won
43
Everything posted by gebeer
-
module Module ImageReference - Pick images from various sources
gebeer replied to gebeer's topic in Modules/Plugins
@adrian I'm with you here. After contemplating some more, I think the page approach should be the only option, discarding the folder option in site/templates/. Since PW is all about pages, this makes more sense. Also editors can easily add/remove images as they see fit without having to use other tools like FTP clients. This also provides the manipulation methods from Pageimage class to all images. What do you all think? -
module Module ImageReference - Pick images from various sources
gebeer replied to gebeer's topic in Modules/Plugins
@adrian While I think that this is a good idea, I am not sure yet, if I want to go that far with this module. This would add additional complexity when installing and I wanted to keep it as simple as possible. This addition would make it kind of a "mini media manager" and I don't know how high the demand for it really would be since we have kongondo's excellent media manager already. But if more people would like to have that option, I can implement it. Please vote. -
module Module ImageReference - Pick images from various sources
gebeer replied to gebeer's topic in Modules/Plugins
Exactly the same thought came to my mind. Will implement this as an option. -
module Module ImageReference - Pick images from various sources
gebeer replied to gebeer's topic in Modules/Plugins
@szabesz Actually I was thinking about making this change, too ? @adrian Great job! Could you make a PR with your changes? I'd like to implement them. This will also make the images instances of Pageimage and we get all image manipulation methods. -
Have you tried httpUrl without the () ? In API docs it states that httpUrl is a property, not a function https://processwire.com/api/ref/pageimage/
-
I fork long running processes to the background. You don't need PCNTL functions for this. In an import module which takes some minutes to run, I have a file "importworker.php" <?php namespace ProcessWire; include(__DIR__ . "/../../../index.php"); // bootstrapping PW error_reporting(2); // setting error reporting // ini_set('max_execution_time', 300); // 300 seconds = 5 minutes wire('log')->save('productimport', "starting import: " . date('Y-m-d H:i:s')); $importModule = wire('modules')->get("ProcessImportProducts"); $importModule->importController('start'); wire('log')->save('productimport', "Import finished: " . date('Y-m-d H:i:s')); Then there is a method for forking the heavy work into the background public function startImportWorker() { $path = $this->config->paths->siteModules . "{$this->className}/"; $command = "php {$path}importworker.php"; $outputFile = "{$path}output.txt"; $pid = shell_exec(sprintf("%s > $outputFile 2>&1 & echo $!", $command)); return; } All output of the importworker script is piped to output.txt. So I can see what happens when the process is running in the background. Some methods in my module echo stuff so I can see it in output.txt. Also for longer running loops in my module, I use the ini_set('max_execution_time', 300) method to prolong execution time. And I unset variables along the way to take care of memory issues. With some ajaxy JS, I get the contents of output.txt and show them inside a div#status in my module, so the user knows that there is sth going on. var ProcessImportProducts = { init: function() { $('#startimport').on('click', function(e){ e.preventDefault(); $.get($(this).data('href'), function( data ) { // console.log(data); ProcessImportProducts.pollResults(0); }); }); }, pollResults: function(timestamp) { var statusUrl = '?getstatus=1'; var statusText = $('#status'); // var loader = $('.loader').clone(); if(!timestamp) statusText.html(''); $.ajax( { type: 'GET', dataType: 'json', url: statusUrl, success: function(data){ // console.log(data); // if file has changed append data to statusText if(timestamp != data.timestamp ) statusText.html(data.message).append('<div class="loader"></div>'); // call the function again, this time with the timestamp we just got from server var timeout = setTimeout(function() { ProcessImportProducts.pollResults(data.timestamp); }, 1000); if(data.timestamp == 0) { clearTimeout(timeout); $('.loader').addClass('hide'); } // scroll to bottom of status div statusText.scrollTop(statusText.prop("scrollHeight")); } } ); } }; $(document).ready(function() { ProcessImportProducts.init(); }); EDIT: heres the part of my ___execute() function, that returns the status stuff for the JS if($this->config->ajax) { if($this->input->start == 1){ $this->startImportWorker(); echo 1; return; } if($this->input->getstatus == 1) $this->returnStatus(); } else { // module output to screen } Here's a good read about running processes in the background: https://medium.com/async-php/multi-process-php-94a4e5a4be05 Hope that helps.
-
I think, the problem is with $page->single_image being of type Pageimages, not Pageimage. Inside hooks the $page object's output formatting is turned off. This means that even for image fields that are defined to hold only 1 image, the field is of type Pageimages, which is an array. You can confirm this by doing var_dump($page->single_image) (or better using Tracydebugger bd($page->single_image)). So to get to the actual image, you need to loop over the Pageimages array like foreach($page->single_image as $image) { // your logic goes in here }
-
I am using this module (v0.2.9) to generate low quality previews for use with lazysizes js using following code $imgLow = $img->pim2Load('lowq', true)->setOptions(['quality' => 20])->pixelate(3)->smooth(255)->pimSave(); This is working fine but I quite frequently get a warning: PHP Warning: rename(/home/m1698/Sites/processwire/site/assets/files/14172/p1010866_geschnitten-1.780x0-pim2-lowq.jpg.tmp,/home/m1698/Sites/processwire/site/assets/files/14172/p1010866_geschnitten-1.780x0-pim2-lowq.jpg): No such file or directory in /home/m1698/Sites/processwire/site/assets/cache/FileCompiler/site/modules/PageImageManipulator/ImageManipulator02.class.php:715 It seems that the warning is thrown by rename() because it is being executed on a non existing file ($dest). Somehow $dest must have been deleted. But strange enough, the renamed file exists. So the rename operation seems to have been run successfully. Any idea what might be causing this?
-
Hello @horst This looks very interesting. Is it available in the module directory? Couldn't find it. I'm currently looking into setting up a site profile that follows atomic design principles. Part of which would be asset management/compilation.
-
Testing Blisk browser, only 1 feature interests me, live reloading
gebeer replied to OrganizedFellow's topic in Dev Talk
I used gulp a lot over the last years. Until I recently stumbled upon @rafaoski's Milligram site profile which utilizes laravel-mix which is a wrapper around webpack that makes setting up your build workflow a no-brainer. Since I am using laradock as my dev environment for the last 2 years, I know that the folks at laravel have some amazing, reliable tools. All this on a linux box. But since it is all node/npm based, it shouldn't be a problem on windows. Especially if using node version manager (nvm) to handle installation and version switching. There is also a node version manager for windows. -
Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often. For those cases it is nice to make some help videos available to editors. This is what this module does. ProcessHelpVideos Module A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors. This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share. The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos If you like to give it a try, I am happy to receive your comments/suggestions here.
-
module Module ImageReference - Pick images from various sources
gebeer posted a topic in Modules/Plugins
Hello all, sharing my new module FieldtypeImageReference. It provides a configurable input field for choosing any type of image from selectable sources. Sources can be: a predefined folder in site/templates/ and/or a page (and optionally its children) and/or the page being edited and/or any page on the site CAUTION: this module is under development and not quite yet in a production-ready state. So please test it carefully. UPDATE: the new version v2.0.0 introduces a breaking change due to renaming the module. If you have an older version already installed, you need to uninstall it and install the latest master version. Module and full description can be found on github https://github.com/gebeer/FieldtypeImageReference Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip Read on for features and use cases. Features Images can be loaded from a folder inside site/templates/ or site/assets Images in that folder can be uploaded and deleted from within the inputfield Images can be loaded from other pages defined in the field settings Images can be organized into categories. Child pages of the main 'image source page' serve as categories mages can be loaded from any page on the site From the API side, images can be manipulated like native ProcessWire images (resizing, cropping etc.), even the images from a folder Image thumbnails are loaded into inputfield by ajax on demand Source images on other pages can be edited from within this field. Markup of SVG images can be rendered inline with `echo $image->svgcontent` Image names are fully searchable through the API $pages->find('fieldname.filename=xyz.png'); $pages->find('fieldname.filename%=xy.png'); Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message with links to help you edit those pages and remove references there before you can finally delete the image. This field type can be used with marcrura's Settings Factory module to store images on settings pages, which was not possible with other image field types When to use ? If you want to let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site (e.g. icons, but not limited to that). Other than the native ProcessWire images field, the images here are not stored per page. Only references to images that live on other pages or inside a folder are stored. This has several advantages: one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Installation and setup instructions can be found on github. Here's how the input field looks like in the page editor: If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip Eventually this will go in the module directory, too. But it needs some more testing before I submit it. So I'd really appreciate your assistance. Thanks to all who contributed their feedback and suggestions which made this module what it is now.- 90 replies
-
- 22
-
@kongondo Thank you for that module. Befor I go and order it, I'd like to make sure that the feature my client needs is included already. For that client each media item should be available as a public download. So in the list of media in the manager there should be something like a button to copy that public link and when editing media that public link should be displayed also. I guess the module needs some customizing to do this. Would this be possible through hooks? Especially for the media lists in the manager. Are there hooks available where I could inject some markup or even an extra column in list view? Since all media are pages, I guess I can hook into ProcessPageEdit for those templates and add the link to display in the page editor screen?
-
Hello all, I can't seem to find a way to translate the notice type for the admin notices, .g. 'Notices, 'Session' etc. The live search tool on the language edit page does not find it. I also did a search through the wire folder and could nowhere find these terms as translatable expressions. Is this just not possible ATM or am I missing something? I also couldn't find a hook in the core that lets me manipulate the notices. Only AdminThemeRenoHelpers has a non-hookable function renderAdminNotices. That is all I could find.
-
Thanks again for this great module. I enjoy working with it. Found a small bug, though. The MatrixArray->getValue() method retrieves the value from a matrix field on wire('page'). So it tries to get the matrix field of the page the code is executed on. This isn't always the page we want to process and where the matrix field actually lives on. I changed MatrixArray.php, line 157 to $value = $this->page->$n->get("$rowSel, $colSel"); // instaed of $value = wire('page')->$n->get("$rowSel, $colSel"); Now it is working fine.
-
Set non default language page names not active by default
gebeer replied to gebeer's topic in Multi-Language Support
Indeed, I don't see a way either. Would be nice to have this as configuration option in the module. Maybe we should file a request to https://github.com/processwire/processwire-requests ?- 7 replies
-
- 1
-
- non default language
- page names
-
(and 2 more)
Tagged with:
-
Set non default language page names not active by default
gebeer replied to gebeer's topic in Multi-Language Support
No, was not looking further. If your code can be implemented as a hook, that would be perfect, I guess.- 7 replies
-
- 1
-
- non default language
- page names
-
(and 2 more)
Tagged with:
-
The addAttachment method requires a file path on the disk, not an url. Try $m->addAttachment ( $page->email_main_img->filename ); See also https://processwire.com/api/ref/pageimage/filename/
-
@BitPoet @Autofahrn Thank you both for clarifying.
-
Hi all, On one of my clients installs which is hosted by Strato, I quite sporadically get DB connection errors like: Exception: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'keepsake.store.d0m.de' The server address is wrong here. It always has the store.d0m.de part in it with varying subdomains like trick, whemper etc. The actual address in config.php is rdbms.strato.de. So how can PW possibly try and connect to that wrong address? Does it point to a hacking attempt or is something wrong with Strato's internal DB server routing during high load times? Anyways, just posting this to see if anyone else has seen behaviour like this before. I'll also ask the Strato support and hope they can shed some light...
-
I just had a similar error message on one of my sites: Uncaught TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given It is not a consisten error, appeared only once in the log. No idea what causes this. Maybe someone can jump in? The site actually uses only 1 language I installed Languages base module so I can have the backend in German.
-
TypeError: a.ProcessPageList is not a function in Admin
gebeer replied to gebeer's topic in General Support
I did not run into this again and it happened only on that one install which has not been upgraded since. So I'm afraid, I can't tell... -
@kongondo Thank you very much for this module. Very useful in a simple shop scenario that I'm building with PW 3.0.125 on PHP 7.2. When I try to dump a Matrix field on a page with bd($p->variationmatrix) I get an error: Exception: Class 'MatrixArray' doesn't yet implement method 'makeBlankItem()' and it needs to. on line: 190 in /var/www/hugoerke.local/wire/core/WireArray.php Just looping over $p->variationmatrix does not throw the exception. As a quick fix, I added the amended original method from WireArray to the MatrixArray Class like this public function makeBlankItem() { $class = wireClassName($this, false); if($class != 'MatrixArray' && $class != 'PaginatedArray') { throw new WireException("Class '$class' doesn't yet implement method 'makeBlankItem()' and it needs to."); } return null; } No more exception now. But still wondering why this happened, maybe something in the core changed that requires every WireArray derived class to redefine this method?
-
With the the relatively new ProField FieldtypeFieldsetGroup it should be a quick job to add this to all templates.
-
Released: Street Address Fieldtype + Inputfield
gebeer replied to netcarver's topic in Modules/Plugins
Is working like a charm ? Thank you!