Jump to content

Zeka

Members
  • Posts

    1,012
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Zeka

  1. Hi @Ivan Gretsky That's how it works for me. In your case, you can create a controller for 'b' template that extends your 'a' template, call the parent init method and then set template for the view class PostsController extends CategoryController { public function init() { parent::init(); $this->view->setTemplate('category'); } }
  2. Hi @rick As error says, a page should be saved before adding to or accessing files from it. Take a look at this thread Probably you have to check for $page->isNew() and $page->id or just save a page before doing somting with files field like $uploadpage = new Page(); $uploadpage->template = "upload-entry"; $uploadpage->title = date("d-m-Y H:i:s") . " - " . uniqid(); $uploadpage->save(); //save page before adding files $uploadpage->images->add($upload_path . $file); // save uploaded files to new page $uploadpage->save(); I don't know the context of your code as the code itself, so it quite hard to say someting more.
  3. Hi @Krlos You can do it by hooking ProcessPageListRender::getPageLabel like here https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L460 https://github.com/FlipZoomMedia/PageHitCounter/blob/master/PageHitCounter.module#L950
  4. $toJSON = $list->explode(function ($item) { return [ 'title' => $item->title, 'id' => $item->id, 'tags' => $item->tags->explode(function($subitem) use($item) { return [ 'id' => $subitem->id, 'title' => $subitem->title, 'parent_title' => $item->title, 'sub_page' => $subitem->page_field->explode(['id', 'title']) ] }) ]; }); You can get more info about explode, each and implode function here https://processwire.com/talk/topic/5098-new-wirearray-api-additions-on-dev/
  5. @ngrmm By the way, you can try to use $pages->findRaw https://processwire.com/api/ref/pages/find-raw/, like wireEncodeJSON($pages->findRaw('template=some-template, parent=1234,', ['id', 'title', 'tags' => ['id', 'title']);
  6. $list = $pages->get(1234)->children; $toJSON = $list->explode(function ($item) { return [ 'title' => $item->title, 'id' => $item->id, 'tags' => $item->tags->explode(['id', 'name', 'title']) ]; });
  7. Hi @ngrmm $list = $pages->get(1234)->children; $toJSON = $list->explode(function ($item) { return [ 'title' => $item->title, 'id' => $item->id, 'tags' => [ 'ids' => $item->page_field->explode('id') ] ]; }); wireEncodeJSON($toJSON);
  8. Hi @lpa It depends on how many pages you have in the system. There is a 'rebuildAll' method in the PagesParents class that runs every time you move a page. Take a look at this issue https://github.com/processwire/processwire-issues/issues/1459 You can try to use transactions if you use InnoDB.
  9. Hi @modifiedcontent It's better to stick to this feature https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users
  10. I have had this issue since the site update, but have never been able to track what is causing it, it's definitely not only 'files'.
  11. Hi @Abe Cube I you are talking about ProcessPageEdit screen, that you can add runtime fields via hook. You can find some info there
  12. * - Inputfields.startSpinner(f): Start spinner for Inputfield. * - Inputfields.stopSpinner(f): Stop spinner for Inputfield.
  13. Hi @Chris Bennett It worth to mention that there is a branch of helpful public methods in Inputfields.js that you can use in such cases https://github.com/processwire/processwire/blob/master/wire/templates-admin/scripts/inputfields.js
  14. Hi @Frank Schneider Have you enabled urlSegments in template settings for mitglied_edit page?
  15. In this way it will generate an image variation and the original image will stay untouched, but as I understood @picaricawant to resize the original image. If so, you can do something like $this->addHookAfter('InputfieldImage::fileAdded', function(HookEvent $event) { $inputfield = $event->object; if ($inputfield->hasField != 'image' && $inputfield->hasField != 'images') return; $image = $event->argumentsByName("pagefile"); $maxSize = 780; $portrait = $image->height > $image->width; $property = $portrait ? 'height' : 'width'; $width = $portrait ? 0 : $maxSize; $height = $portrait ? $maxSize : 0; // if the current size exceeds the max, proceed a resize if ($image->$property >= $maxSize) { $is = new ImageSizer($image->filename, ['quality' => 100]); $done = $is->resize($width, $height); } });
  16. Hi @Juergen Try to set current user language to the langauge that are set for user to which you are sending mail like protected function sendActivationLinkEmail(User $user): bool { $savedLanguage = $this->wire('user')->language; $this->wire('user')->language = $user->language; // send an email with the activation link to the user // but check first if activation code (fl_activation) exists inside the database if($user->fl_activation){ $m = wireMail(); $m->to($user->email); $m->from($this->input_email); $m->subject($this->_('Action required to activate your account')); $m->body($this->createActivationLinkEmail($user)); $m->mailTemplate($this->input_emailTemplate); return $m->send(); } $this->wire('user')->language = $savedLanguage; return false; }
  17. Hi @Bike There is Textformatter type of modules that are applicable in such cases. You can take a look at this module https://github.com/Toutouwai/TextformatterProcessImages from @Robin S Probably it can suit your needs or at least you can use it as a staring point.
  18. Hi @rushy AFAK there is no built-in option. There is a way how you can override core modules https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module. After that you can adopt 'getAdminThumb' method so your default image variation will match one that you are using on the frontend. Potentially there could be some issues with admin UI.
  19. Hi @picarica You can achive it by hooking InputfieldFile::fileAdded like in the example below: $this->wire()->addHookAfter('InputfieldFile::fileAdded', function ($event) { $inputfield = $event->object; if ($inputfield->hasField != 'image' && $inputfield->hasField != 'images') return; $image = $event->argumentsByName("pagefile"); // Main post image if ($inputfield->hasField == 'image' && $inputfield->hasPage && $inputfield->hasPage->template->name == 'post') { $image->size('postMainImageSmall'); $image->size('postMainImageMedium'); $image->size('postMainImageMediumPortrait'); $image->size('postMainImageLarge'); } // Matrix block 'Gallery' if ($inputfield->hasField == 'images' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 5 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockGallerySmall'); $image->size('postBlockGalleryMedium'); $image->size('postBlockGalleryLarge'); $image->maxSize(config('imageSizes')['postBlockGalleryLarge']['width'], config('imageSizes')['postBlockGalleryLarge']['width']); } // Matrix block 'Slider' if ($inputfield->hasField == 'images' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 6 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockGallerySmall'); $image->size('postBlockGalleryMedium'); $image->size('postBlockGalleryLarge'); $image->maxSize(config('imageSizes')['postBlockSliderLarge']['width'], config('imageSizes')['postBlockSliderLarge']['width']); } // Matrix block 'Image' if ($inputfield->hasField == 'image' && $inputfield->hasPage && $inputfield->hasPage->repeater_matrix_type == 7 && $inputfield->hasPage->template->name == 'repeater_builder') { $image->size('postBlockImageSmall'); $image->size('postBlockImageMedium'); $image->size('postBlockImageLarge'); $image->maxSize(config('imageSizes')['postBlockImageLarge']['width'], config('imageSizes')['postBlockImageLarge']['width']); } });
×
×
  • Create New...