martind Posted August 13, 2015 Share Posted August 13, 2015 no problem, your suggestion to do it by a new inputfield-file variant works perfect, i have a multiple-file field now, that executes the imagick scaling after upload und shows the generated thumbnail in the file-list. pretty good for the first step, as i think. 1 Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 is it possible, to add one of the generated images from the new file-field to an existing image-field on the same template? Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 14, 2015 Share Posted August 14, 2015 Sure. $page->imageField->add($path); Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 Sure. $page->imageField->add($path); Thank you kobrakai, i`ve problems to get the $page varible in my inputfield module. i'm not really familiar with modules in general, so maybe i don`t understand someting common here. Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 14, 2015 Share Posted August 14, 2015 Depends on which hook you're using, if you're using hooks. Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 no. i've cloned the inputfield-file module to InputfieldFileApp.module (and copied FieldtypeFile.module as FieldtypeFileApp.module inside the folder). The new filefield works, i can use some custom functions inside, this is good. But now, i want to copy a specific version of a new uploaded file to another field, an image field on the same template. inside InputfieldFileApp.module wire('page') is the edit page, not the page the field is on. thats logical, but doesn't help me out. Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 ...inside InputfieldFileApp.module wire('page') is the edit page, not the page the field is on. thats logical, but doesn't help me out. https://processwire.com/talk/topic/2691-getting-current-page-in-a-inputfield-or-fieldtype-module/ ... in this post the behavour got discussed, but i cant get ryans solution to work. Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 14, 2015 Share Posted August 14, 2015 It would be more "update-prove" to just hook the existing modules and add in your needed function on runtime, but this works, too. Most inputfields work independent on any page context, like the file field. Therefore the Fieldtype does add some hooks to dynamically inject this information, to cater for changing uploadPaths (see setupHook). You could edit the called function to not only inject the path, but also the $page object into the inputfield. Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 ok, thank, that helped, declaring $inputfield->editPage = $page; in the Fieldtypes hookProcessInput function i have the page-object in the inputfield module. inside the ProcessInput function i create my image variants and with $this->editPage->app_img->add($this->destinationPath.$filename."-app-web.jpg"); $this->editPage->save(); ... i can copy the image to the app_img field in the background and it appears when saving the page. Is it possible to actualize the image-field after the add() is done? Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 14, 2015 Share Posted August 14, 2015 That's not easily possible as the server cannot tell the client that there's a new image without the client actually requesting data from the server. You'd need to change the javascript of the image field to do some kind of server polling and requesting new images. Link to comment Share on other sites More sharing options...
martind Posted August 14, 2015 Share Posted August 14, 2015 ok, thats something i can live with, thank you. another question: when using something like $this->message($this->_("blabla...")); in the inputfield module we spoke about, shouldn`t this work? Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 14, 2015 Share Posted August 14, 2015 Depends on where you're doing this and if you're using SystemNotifications. With the module enabled I had times, where messages invoked shortly before a redirect where gone after the redirect. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now