Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/01/2025 in all areas

  1. I’ve been working on a module to store ProcessWire files directly on Backblaze B2, and wanted to share it with the community. Why I Built This I needed to host video content without breaking the bank on storage costs. AWS S3 was too expensive, and I wanted something that integrates seamlessly with ProcessWire’s existing file fields. Key Features 🚀 Direct B2 Upload - Files go straight to Backblaze, no local storage needed 💰 Dirt Cheap - $6/TB/month (AWS S3 costs 5x more) 🌐 Custom Domain Support - Use your own CDN domain ⚡ Cloudflare Integration - Combine with Cloudflare for FREE bandwidth 📦 Works with Repeaters - Multiple files per repeater item 🎬 Perfect for Video - Tested with Plyr, Video.js, and HTML5 video Real Cost Savings Here’s what I’m actually paying for 500GB of video storage: Backblaze B2 + Cloudflare: - Storage: $3/month - Bandwidth: $0 (free via Cloudflare Bandwidth Alliance) - Total: $3/month AWS S3 (same usage): - Storage: $11.50/month - Bandwidth: $450/month (5TB) - Total: $461.50/month That’s a 99% savings on bandwidth costs! How It Works The module extends ProcessWire’s file fields to upload directly to Backblaze B2. You can use it just like regular file fields: // Single video <video controls> <source src="<?= $page->b2_video->url ?>" type="video/mp4"> </video> // Multiple videos in repeater <?php foreach($page->videos as $item): ?> <?php foreach($item->b2_video as $video): ?> <video controls> <source src="<?= $video->b2url ?>" type="video/mp4"> </video> <?php endforeach; ?> <?php endforeach; ?> Cloudflare CDN Integration Want free bandwidth? Here’s the magic setup: CNAME: cdn.yourdomain.com → f005.backblazeb2.com (with Cloudflare proxy) Transform Rule: Rewrite paths to include /file/bucket-name/ Module setting: Enable custom domain Now all files serve through Cloudflare’s global CDN with zero bandwidth costs thanks to the Bandwidth Alliance partnership. Setup is Simple Create Backblaze B2 bucket Configure module with API keys Create field (type: FieldtypeFileB2) Add field to template Upload files - they go straight to B2! Optional: Add Cloudflare for free bandwidth and caching. Use Cases Video hosting (my use case) Large image galleries Audio files / podcasts Downloadable resources Any high-bandwidth file hosting Technical Details Works with public and private buckets Supports custom Cache-Control headers Files are deleted from local server after upload Can use custom domains via Cloudflare CORS configurable for cross-domain access Try It Out GitHub: https://github.com/mxmsmnv/FieldtypeFileB2
    8 points
  2. Nested Checkboxes An inputfield for Page Reference fields that groups options by their parent page, and optionally by grandparent page too. This can help editors understand the grouping of the selectable pages, and also makes it quicker for an editor to select or unselect an entire group of pages. The checkboxes at the parent and grandparent level are not for storing those pages in the field value - only for quickly selecting or unselecting groups of pages at the lowest level of the hierarchy. For example, in the screen recording above the "Cities" Page Reference field allows only pages with the "city" template, and the pages at the country and continent level are not included in the field value. The inputfield is only for use with Page Reference fields because the structure comes from the page tree. Requires PW >= v3.0.248. Configuration For each field that uses the inputfield you have these options: Checkboxes structure: choose "Parents" or "Parents and grandparents". Collapse sections that contain no checked checkboxes: this option makes the inputfield more compact. There are also the standard column width and column quantity options familiar from the InputfieldCheckboxes inputfield. These apply to the selectable pages at the lowest level of the hierarchy, and the structure is arguably more readable when these are left at their defaults. https://github.com/Toutouwai/InputfieldNestedCheckboxes https://processwire.com/modules/inputfield-nested-checkboxes/
    3 points
  3. Hey everyone! After the StripePaymentLinks module has been running smoothly, a few customers with multiple Stripe accounts asked for better analytics capabilities. The Stripe dashboard is okay, but when you have multiple accounts and need specific analysis, it quickly becomes tedious. StripePlAdmin is an admin interface that displays the data stored by StripePaymentLinks in three perspectives: Purchases: All transactions with customer details, subscription status, renewals Products: Aggregated product performance (revenue, purchases, quantities) Customers: Customer lifetime value, purchase behavior Features: Configurable columns per tab Dynamic filters (Boolean search, date ranges, number ranges) Clickable product/customer names open detail modals CSV export with active filters Summary totals at table footer You can show/hide columns and filters in the module settings as needed. Everything is very flexible. Available on GitHub and in the Modules directory. Feedback welcome! 🚀 Cheers, Mike
    2 points
  4. If you dynamically add parameters to your link, you can use them in a hook: $wire->addHookBefore('Pages2Pdf::download', function($event) { /** @var Pages2Pdf $module */ $module = $event->object; $input = $event->wire('input'); $sanitizer = $event->wire('sanitizer'); // 1. Check if we are in your specific scenario // (Optional: limit this to specific templates if needed) $page = $event->arguments(0); if($page->template != 'your-list-template') return; // 2. Retrieve your filter parameters from the URL // Example URL: ?pages2pdf=1&filter_category=music&date=2023 $category = $input->get('filter_category'); $date = $input->get('date'); // 3. Build a safe filename string // It is crucial to sanitize these inputs to avoid invalid filesystem characters $filenameParts = [$page->name]; if($category) { $filenameParts[] = $sanitizer->pageName($category); } if($date) { $filenameParts[] = $sanitizer->pageName($date); } // Add unique ID or timestamp if you want to avoid caching conflicts completely // $filenameParts[] = time(); $newFilename = implode('-', $filenameParts) . '.pdf'; // 4. Overwrite the module setting for this specific request $module->set('filename', $newFilename); }); Important: The hook must be implemented via init.php. It does not work in ready.php. Actually tested it here to add the amount of portions into the filename: https://www.dothiscookingthing.de/rezepte/lachs-spiesse-mit-garnelen-aus-dem-ofen/
    1 point
  5. This works to replace the ___execute method to select a default page for pages that don't contain image fields: public function ___execute() { if($this->config->demo) throw new WireException("Sorry, image editing functions are disabled in demo mode"); if(!$this->page) { $error = "No page provided"; $this->error($error); return "<p>$error</p>"; } $sanitizer = $this->wire()->sanitizer; $modules = $this->wire()->modules; $input = $this->wire()->input; $images = $this->getImages($this->page, $this->page->fields); $pickpage = false; // locate any image fields $imageFields = $this->getImageFields($this->page); if (!wireCount($imageFields)) { $default = @$this->data['defaultPage'] ?: false; if ($default > 0) { $pg = $this->wire->pages->get($default); if ($pg->id > 0) { $this->page = $pg; $pickpage = true; } } // Selector page by template selection in module config: $pgByTpl = @$this->data['templateDefaultPage']; if (!empty($pgByTpl)) { $lines = explode("\n", $pgByTpl); foreach ($lines as $line) { $pcs = explode(':', $line); if (count($pcs) < 2) continue; $tpl = wire('templates')->get($pcs[0]); $pg = wire('pages')->get($pcs[1]); if ($tpl->id == $this->editorPage->template->id) { $pickpage = true; $this->page = $pg; break; } } } if ($pickpage) $this->message('Default images selection page set'); $images = $this->getImages($this->page, $this->page->fields); // locate image fields from default $imageFields = $this->getImageFields($this->page); } if(wireCount($imageFields)) { $imageFieldNames = implode(',', array_keys($imageFields)); /** @var InputfieldButton $btn */ $btn = $modules->get('InputfieldButton'); $uploadOnlyMode = "$this->page" === "$this->editorPage" ? 1 : 2; $btn->href = "../edit/?modal=1&id={$this->page->id}&fields=$imageFieldNames&uploadOnlyMode=$uploadOnlyMode"; $btn->value = $this->_('Upload Image'); $btn->addClass('upload pw-modal-button pw-modal-button-visible'); $btn->icon = 'upload'; $changes = $input->get('changes'); if($changes) { foreach(explode(',', $changes) as $name) { $name = $sanitizer->fieldName($name); $field = $this->wire()->fields->get($name); if(!$field) continue; $out .= "<script>refreshPageEditField('$name');</script>"; } } } else $btn = null; if($this->input->get('file')) return $this->executeEdit(); // initialization of variables was here $out = ''; if(wireCount($images)) { $winwidth = (int) $input->get('winwidth'); $in = $modules->get('InputfieldImage'); /** @var InputfieldImage $in */ $in->set('adminThumbs', true); $lastFieldLabel = ''; $numImageFields = 0; foreach($images as $image) { /** @var PageImage $image */ $fieldLabels = array(); $parentFields = $image->get('_parentFields'); if(!is_array($parentFields)) $parentFields = array(); foreach($parentFields as $parentField) { $fieldLabels[] = $parentField->getLabel(); } $fieldLabels[] = $image->field->getLabel(); $fieldLabel = implode(' > ', $fieldLabels); if($fieldLabel != $lastFieldLabel) { $numImageFields++; $out .= "\n\t<li class='select_images_field_label detail'>" . $sanitizer->entities($fieldLabel) . "</li>"; } $lastFieldLabel = $fieldLabel; if($this->noThumbs) { $width = $image->width(); $alt = $sanitizer->entities1($image->description); if($width > $this->maxImageWidth) $width = $this->maxImageWidth; $img = "<img src='$image->URL' width='$width' alt=\"$alt\" />"; } else { $image->set('_requireHeight', true); // recognized by InputfieldImage $info = $in->getAdminThumb($image); $img = $info['markup']; } $out .= "\n\t<li><a href='./edit?file={$image->page->id},{$image->basename}" . "&amp;modal=1&amp;id={$this->page->id}&amp;winwidth=$winwidth'>$img</a></li>"; } $class = $this->noThumbs ? "" : "thumbs"; if($numImageFields > 1) $class = trim("$class multifield"); $out = "\n<ul id='select_images' class='$class'>$out\n</ul>"; } /** @var InputfieldForm $form */ $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "get"; /** @var InputfieldPageListSelect $field */ $field = $modules->get("InputfieldPageListSelect"); $field->label = $this->_("Images on Page:") . ' ' . $this->page->get("title") . " (" . $this->page->path . ")"; // Headline for page selection, precedes current page title/url $field->description = $this->_("If you would like to select images from another page, select the page below."); // Instruction on how to select another page $field->attr('id+name', 'page_id'); $field->value = $this->page->id; $field->parent_id = 0; $field->collapsed = wireCount($images) ? Inputfield::collapsedYes : Inputfield::collapsedNo; $field->required = true; $form->append($field); // getImageFields was here $out = $form->render() . $out; if($btn) $out .= $btn->render(); return "<div id='ProcessPageEditImageSelect'>" . $out . "\n</div>"; } Add these fields to getModuleConfigInputFields method: /** @var InputfieldPageListSelect $f */ $f = $modules->get('InputfieldPageListSelect'); $f->attr('name', 'defaultPage'); $f->attr('value', @$data['defaultPage']); $f->label = $this->_('Default Page if no image fields'); $f->value = @$data['defaultPage']; $inputfields->add($f); /** @var InputfieldPageListSelect $f */ $f = $modules->get('InputfieldTextarea'); $f->attr('name', 'templateDefaultPage'); $f->attr('value', @$data['templateDefaultPage']); $f->label = $this->_('Default page by template for images if no image fields'); $f->notes = "1 pair of selectors `{template}:{page}` per line, e.g.,: `1:/home/`, or `home:1`, or `contact:template=home`"; $f->value = @$data['templateDefaultPage']; $inputfields->add($f); Copy the entire module directory into your site modules directory.
    1 point
  6. BC Drive Website needs updates and was built on Processwire website I believe 2.7 I can be reached at 604-989-8802 for further details. Thanks so much, Tania
    1 point
×
×
  • Create New...