Search the Community
Showing results for 'template'.
-
I wanted a way to chat with my Processwire site and built a Module (PW MCP) and an MCP server to connect into it. It's a private repo at the moment but it can be public if anyone finds it useful. It's basically a way to use the Cursor Chat Ui to query my site, fields, templates and content. Here's part of the readme which explains it better. What Is It? ProcessWire MCP is a bridge between ProcessWire and Cursor IDE (the AI-powered code editor). It lets you query your ProcessWire site's structure and content directly from Cursor's chat interface using natural language. Instead of writing selectors or browsing the admin, you can just ask: "What templates does this site have?" "Show me the fields on the blog-post template" "Search for pages containing 'summer'" "Find all images with 'lake' in the filename" Why I Built It Cursor can see your template files and code in the local directory, but it can't see what's actually in your ProcessWire database — which templates and fields are registered, what pages exist, or what content they contain. With ProcessWire MCP, the AI can: Query the actual database schema (not just parse template files) Look up page content by ID, path, or selector Understand field configurations (types, settings, which templates use them) Search across all text content and find files/images Get RepeaterMatrix content with type labels See file metadata (dimensions, descriptions, URLs) It's the difference between seeing $page->body in code vs. knowing what that page's body actually contains. Architecture Cursor Chat → MCP Server (Node.js) → PHP CLI → ProcessWire API The module consists of: PwMcp — A ProcessWire module with a CLI interface mcp-server — A Node.js server that speaks the Model Context Protocol The CLI can also be used standalone for quick queries from terminal. Available Commands Command Description health Check connection and get site info list-templates List all templates with field counts get-template [name] Get template details and fields list-fields List all fields with types get-field [name] Get field details and usage get-page [id\|path] Get page by ID or path with all field values query-pages [selector] Query pages using PW selectors search [query] Search content across all text fields search-files [query] Search files by name/extension export-schema Export complete site schema Example: Health Check php site/modules/PwMcp/bin/pw-mcp.php health --pretty { "status": "ok", "pwVersion": "3.0.241", "siteName": "www.example.com", "moduleLoaded": true, "counts": { "templates": 45, "fields": 72, "pages": 960 } } Example: Content Search Ask Cursor: "Search for pages containing 'summer'" { "query": "summer", "count": 5, "results": [ { "id": 1764, "title": "Lake District walks in summer", "path": "/guides/lake-district-summer/", "template": "page-guide", "matchedField": "Body", "snippet": "The Lake District offers some of the best walking trails in summer. From gentle lakeside strolls to challenging fell walks..." } ] } Example: File Search Ask Cursor: "Find images with 'lake' in the filename" { "query": "lake", "count": 5, "results": [ { "filename": "lake-windermere-sunset.jpg", "url": "/site/assets/files/1070/lake-windermere-sunset.jpg", "size": 31207, "sizeStr": "30.5 kB", "description": "Sunset over Lake Windermere", "field": "Images", "page": { "id": 1070, "title": "Lake District walks in summer", "path": "/guides/lake-district-summer/" }, "width": 500, "height": 626 } ] } Example: Get Page with All Fields Ask Cursor: "Get the page at /about/" { "id": 1050, "name": "about", "path": "/about/", "url": "/about/", "template": "basic-page", "status": 1, "statusName": "published", "parent": { "id": 1, "path": "/", "title": "Home" }, "numChildren": 5, "created": "2023-05-15T10:30:00+00:00", "modified": "2024-11-20T14:22:00+00:00", "fields": { "title": "About Us", "body": "<p>We are a team of dedicated professionals...</p>", "Images": { "_count": 2, "_files": ["team-photo.jpg", "office.jpg"] } } } Example: RepeaterMatrix Support The module fully supports RepeaterMatrix fields, returning the actual content with type labels: { "matrix": { "_count": 3, "_items": [ { "_typeId": 1, "_typeLabel": "Body", "Body": "<h2>Welcome to our guide</h2><p>This guide covers...</p>", "Images": null }, { "_typeId": 2, "_typeLabel": "FAQs", "faq_question": "What is the best time to visit?", "faq_answer": "The summer months offer the best weather for walking..." }, { "_typeId": 3, "_typeLabel": "Call to Action", "cta_title": "Plan Your Visit", "cta_link": "/contact/" } ] } } So thats the first part done and working. My next plan is to be able to 1. PULL / convert a databse page into a local text file which lists all page properties, fields, template etc 2. edit the file as a local text file 3 PUSH the text file back into PW so that the original content picks up the changes Just having fun and building something useful. Very likely there are similar solutions or better ways to handle this but this suits my workflow ATM. Cheers P
-
Export your ProcessWire site structure as comprehensive, AI-optimized documentation for ChatGPT, Claude, Copilot, and other AI coding assistants. What It Does Context automatically generates complete documentation of your ProcessWire site in formats specifically optimized for working with AI: 📊 Site Structure Complete page hierarchy exported as JSON, TOON, and ASCII tree Shows all relationships, templates, URLs, and metadata Smart collapsing for large page lists 📋 Templates & Fields All template definitions with complete field configurations Field types, options, requirements, default values Special handling for Repeater, Matrix, Table fields 📦 Content Samples Real page examples exported for each template Shows actual data formats and field usage Helps AI understand your content patterns 💾 Code Snippets Customized selector patterns for your site type Helper functions and utility code API implementation examples 🤖 AI Prompts Ready-to-use project context file Template creation prompts Debugging assistance prompts Dual Format Export (The Game Changer!) Context exports in two formats simultaneously: JSON Format Standard format for development tools, APIs, and compatibility TOON Format (AI-Optimized) ✨ Token-Oriented Object Notation designed specifically for AI prompts: 30-60% fewer tokens than JSON Significantly reduces API costs Same data, more compact representation No external dependencies - pure PHP Real Savings Example For a typical ProcessWire site with 50 templates: structure.json (15,000 tokens) → structure.toon (8,500 tokens) = 43% savings templates.json (8,000 tokens) → templates.toon (4,000 tokens) = 50% savings samples/*.json (12,000 tokens) → samples/*.toon (6,500 tokens) = 46% savings Cost Impact (Claude Sonnet pricing): JSON export: $0.105 per AI interaction TOON export: $0.057 per AI interaction Save ~$5/month if you use AI assistants 100 times/month Installation cd /site/modules/ git clone https://github.com/mxmsmnv/Context.git Then in admin: Modules → Refresh → Install Or download from ProcessWire Modules Directory Quick Start Setup → Modules → Context → Configure Choose your site type (Blog, E-commerce, Business, Catalog, Generic) ✅ Enable "Export TOON Format" (recommended for AI work!) Enable optional features: ✅ Export Content Samples ✅ Create Code Snippets ✅ Create AI Prompts Click "Export Context for AI" Files appear in /site/assets/context/ Generated Files /site/assets/context/ ├── README.md # Complete documentation ├── structure.json / .toon # Page hierarchy ├── structure.txt # ASCII tree ├── templates.json / .toon # All templates & fields ├── config.json / .toon # Site configuration ├── modules.json / .toon # Installed modules ├── classes.json / .toon # Custom Page classes │ ├── samples/ # Real content examples │ ├── product-samples.json │ └── product-samples.toon # 46% smaller! │ ├── snippets/ # Code patterns │ ├── selectors.php # Customized for your site type │ ├── helpers.php # Utility functions │ └── api-examples.php # REST API examples │ └── prompts/ # AI instructions └── project-context.md # Complete project overview Using with AI Assistants Upload TOON files to save tokens and costs: 📎 structure.toon 📎 templates.toon 📎 prompts/project-context.md Then ask your AI assistant: "Help me create a blog post template with title, body, author, categories, and featured image. Follow the existing patterns from templates.toon" The AI has complete context of your site and can generate code that follows your exact patterns! Site Type Customization Code snippets automatically adapt to your site type: Blog / News / Magazine Post listings, author archives, category filtering Recent posts, popular content, related articles E-commerce / Online Store Product listings, cart logic, order processing Inventory management, payment integration Business / Portfolio / Agency Service pages, team members, case studies Testimonials, project galleries Catalog / Directory / Listings Brand hierarchies, category filters Advanced search, sorting, pagination Generic / Mixed Content General purpose patterns for any site type Features Overview Always Exported (Core) ✅ Complete page tree structure ✅ All templates with field definitions ✅ Site configuration and settings ✅ Installed modules list ✅ Custom Page classes ✅ README with complete documentation Optional (Configurable) ⚙️ Content samples (1-10 per template) ⚙️ API JSON schemas ⚙️ URL routing structure ⚙️ Performance metrics ⚙️ Code snippets library ⚙️ AI prompt templates ⚙️ IDE integration files (.cursorrules, .claudecode.json) Advanced Settings Auto-update on template/field changes Maximum tree depth (3-20 levels) JSON children limit (prevent huge files) Compact mode for large lists Custom AI instructions Why TOON Format? TOON is specifically designed for AI prompts. Here's the difference: JSON (verbose): { "products": [ {"id": 1, "title": "Dark Chocolate", "price": 12.99}, {"id": 2, "title": "Milk Chocolate", "price": 9.99} ] } TOON (compact): products[2]{id,title,price}: 1,Dark Chocolate,12.99 2,Milk Chocolate,9.99 Same data, 50% fewer tokens! Use Cases 🤖 AI-Assisted Development Upload your site context to Claude/ChatGPT and get code that follows your exact patterns 📚 Developer Onboarding New team members get complete site documentation instantly 🔄 Site Migration Export complete site structure for documentation or migration planning 📖 Code Standards Maintain consistency across your team with AI that knows your patterns 💰 Cost Optimization Reduce AI API costs by 30-60% with TOON format Links GitHub: https://github.com/mxmsmnv/Context TOON Format Spec: https://toonformat.dev Screenshots Example Workflow Export your site Click one button, get complete documentation in both JSON and TOON formats Upload to AI Upload .toon files to Claude/ChatGPT for maximum efficiency Build features faster AI knows your exact site structure, templates, and patterns Save money Use 30-60% fewer tokens on every AI interaction Perfect for ProcessWire developers who use AI coding assistants! The TOON format support makes it significantly more cost-effective to work with Claude, ChatGPT, and similar tools. Questions? Suggestions? Let me know! 🚀
-
I've been working on sites where the standard sitemap setup started showing cracks: XML generated on every request eating memory, no way to regenerate automatically without writing custom hooks, and no visibility into what actually ended up in the file. So I built Sitemap — a module that generates static XML files to disk, splits output by template name, and handles the full lifecycle from generation to search engine notification. What it does differently: Writes files to disk instead of rendering in memory — no RAM spike on large sites Pages are fetched in chunks of 500 with uncacheAll(), so memory stays flat regardless of page count Each template gets its own named file: sitemap-product.xml, sitemap-blog.xml, etc. — the index at sitemap.xml references them all Auto-regeneration via LazyCron with a configurable interval; the LazyCron hook slot is chosen dynamically to match what you configured (every hour, every 6 hours, daily, etc.) rather than always using everyHour A needs_regen flag is set whenever a page is saved, trashed, or deleted — visible in the admin dashboard IndexNow support: after generation, all URLs are submitted to api.indexnow.org in batches of 10,000 Sitemap: directive written directly to the physical robots.txt on save and on generate Lock file prevents concurrent generation Admin dashboard at Setup > Sitemap showing file count, URL count, total size, and last generated time Settings stored in a dedicated DB table (sitemap_settings, name/value, MEDIUMTEXT) rather than the module's data field — avoids the serialized config size limit when template settings grow large. Image sitemap extension and hreflang alternate links for multilanguage sites are both supported. GitHub: https://github.com/mxmsmnv/Sitemap Screenshots: Still v1.0.0, so feedback is very welcome — especially from anyone running it on a site with 10k+ pages.
- 3 replies
-
- 15
-
-
-
Hi all, I have a very simple template for my index-page, but I'm running into a little problem. On the template there is a multi-image field (for a carousel on the homepage). There is also a CKEditor-textfield for the text that is supposed to show up somewhere below that. However, when I want to put an image in there, it will use the image-field for the carousel to upload the images. This means that it will have to meet the requirements of that (minimum dimensions in this case), that should not apply to images that will be used in the text-field. I also think (I haven't tried it out though) that the images uploaded through CKEditor would show up in the carousel, which is obviously not the intention. Since this is a very basic setup, I think this will have happened to a lot of users. I'm therefore curious how to solve this.
-
Hello community, to my surprise and delight, my module “FrontendAutoReload”, which was previously only published on Github and used exclusively by me, was presented in the ProcessWire Weekly Newsletter #545. And because I haven't encountered any problems using it so far, I'm in the process of submitting it to the module repository. It's basically a little helper for ProcessWire template development, which automatically hits the refresh button in your browser each time a change in the template folder is detected. Not groundbreaking but a convienient timesafer. I would therefore be delighted if it could also be of some help to other developers. For information on how to use it, check out FrontentAutoReload on Github. If you have any questions, don't hesitate to ask them.
-
There may be a time where you need to create a page reference field using the Select inputfield and it's selecting repeater pages. Let's say I have a repeater field called "order_line_items" and I want to create a page reference field called "order_line_item" that allows me to select a repeater item (which is a page) of the "order_line_items" repeater field. Repeater pages are a bit different from regular pages in that their "parent" is a container admin page associated with the page in which it exists (dig into /admin/repeaters/order_line_items/ in your page tree to see what I mean). So when you are configuring your page reference field, you can't really choose a Parent. However when configuring your field, your instinct would be to choose the Template of "repeater_order_line_items". Then because you need extra precision in what pages are actually available for selection (rather than all of them across all pages), your instinct will be to implement custom PHP code: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'order_line_item') { $event->return = $event->pages->find('your selector here'); } }); The problem with that approach is that even though you have defined the custom PHP code and the select field correctly shows the selectable repeater pages in the select field, behind-the-scenes, ProcessWire has still loaded EVERY SINGLE REPEATER that has the "repeater_order_line_items" template (you can see this is TracyDebugger's pages loaded list)! Your site will definitely be slower as a result, dramatically so if you have thousands or tens of thousands of repeater pages of that template. I hit this issue years ago (2018) and I thought it was a bug. I discussed it with Ryan and it's technically not a bug, but kind of the way ProcessWire works, which is beyond this tutorial. While you can circumvent this using the PageAutocomplete field, I don't like the ergonomics of that field in certain situations. I want the good-old select field. The solution to this is to NOT select anything for the "Template" when configuring your field. So in my example, I chose "repeater_order_line_items", but instead, it should be left blank. Now the field will just rely on the code portion and all the unnecessary page loads will be eliminated.
-
Hi, Yesterday I found out about the relatively new markup regions functionality and I love it. The ease of use and simplicity is just what I think is typically ProcessWire and is why Im still happy I chose for PW four years ago when changing CMS/CMF. So thanks Ryan for your vision and all you put into it. That said, Im running into an issue I'm not sure what to think of it. I have enabled markup regions in config.php and it does what I suppose it should: it replaced and all. Very neatly. The only thing I discovered is that while Im debugging some issues and I use var_dump to echo some stuff, it does that two times in a row. And this only happens when useMarkupRegions is enabled. I dont get this, does it mean the template file gets called twice (and thus the script is run twice?) or is it only displayed twice, where the first time most output is erased and /or replaced by the substituted output? I don't really get whats going on there. Is this behavior normal when using markup regions? Thanks!
-
I made a small module called ProcessSiteSettings and thought I’d share it here in case it’s useful to someone. ProcessSiteSettings is a lightweight ProcessWire module for storing and editing global site values in one place. There are already similar modules available, so this is simply another free option with a focus on quick setup, usability, and helpful template snippets. It adds a Settings item to the ProcessWire admin menu and creates one central page for global site values like: copyright text footer content contact info social links SEO / AI summary text images repeaters Repeater Matrix page references other regular PW fields Ofc. add your own fields of choice to it, or delete the ones you don't need! It uses a normal template + page approach instead of a fake config form, so it works much more naturally with ProcessWire fields. It also includes a small helper box on the settings edit screen that shows ready-to-use template snippets for each field. It tries to generate smarter examples depending on the field type, including more complex fields like images, repeaters, matrix items, multi-value fields, etc. Settings Menu: Editing Values, adding/deleting custom fields and shortcut to Fields for quick creation of new ones. Quick helper for showing everything on frontend! Example usage on templates: <?= siteSettings('ss_copyright_text'); ?> <?= siteSettings()->ss_footer_text; ?> <?= $siteSettings->ss_contact_email; ?> The admin is in English and the module is translation-ready. Just install the module, and that's it! Just sharing it here in case someone finds it useful. Download Here: ProcessSiteSettings.zip
-
- 8
-
-
-
The problem is obviously with OVH not allowing the script. It made me move to the free cron-job.org service. I've been testing for a day now and it works well when the mail is sent to my own address. From tomorrow on the job is scheduled to go once a day to blogger.com to post from mail there. One change between my old php 5 and 8.2 is that "template==template_name" should now be "template=='template_name'".
-
Hi, After reading this thread, I decided to make a module that helps generating PDF files of ProcessWire pages. GitHub: https://github.com/wanze/Pages2Pdf Modules Directory: http://modules.processwire.com/modules/pages2-pdf/ This module uses the mPDF library to generate the PDF files. It has fully UTF-8 and basic HTML/CSS support for rendering the PDF files. The output is customizable with ProcessWire templates. Example I've enabled generating PDF files for the skyscraper template of ryans Skyscrapers-profile with a template that outputs the data in a table along with the body text and the images: one-atlantic-center-pdf-4177.pdf Please take a look at the README on GitHub for instructions and further information/examples. Cheers
- 354 replies
-
- 33
-
-
I haven't made my site live yet but I have a similar issue. I'm developing on laragon, and my Processwire site was installed with a folder /pw-template/ such that the site loads at: http://localhost/pw-template/ So far I've tried the following: - moving everthing in /pw-template/ to the root / - adding the following lines to config: $config->urls->root = '/'; $config->urls->admin = '/processwire/'; - deleting cache files in the site folder - doing a hard reload in the browser The site pages seem to load fine, but the Admin is not working correctly. Selecting Pages for example returns url http://localhost/pw-template/processwire/page/ so something hasnt been updated. Do I need to play with the database? I'm terrified of screwing up my database and progress and I'm not used to playing with MySQL. If I do something with the htaccess file is there a risk of breaking something in the database? I'm using laragon for the moment. When development is finished, I'd like to migrate or clone everything to the server if possible. Not sure how recommended that is if I change the root - hoping this doesn't screw up installed modules...
-
This module is inspired by and similar to the Template Stubs module. The author of that module has not been active in the PW community for several years now and parts of the code for that module didn't make sense to me, so I decided to create my own module. Auto Template Stubs has only been tested with PhpStorm because that is the IDE that I use. Auto Template Stubs Automatically creates stub files for templates when fields or fieldgroups are saved. Stub files are useful if you are using an IDE (e.g. PhpStorm) that provides code assistance - the stub files let the IDE know what fields exist in each template and what data type each field returns. Depending on your IDE's features you get benefits such as code completion for field names as you type, type inference, inspection, documentation, etc. Installation Install the Auto Template Stubs module. Configuration You can change the class name prefix setting in the module config if you like. It's good to use a class name prefix because it reduces the chance that the class name will clash with an existing class name. The directory path used to store the stub files is configurable. There is a checkbox to manually trigger the regeneration of all stub files if needed. Usage Add a line near the top of each of your template files to tell your IDE what stub class name to associate with the $page variable within the template file. For example, with the default class name prefix you would add the following line at the top of the home.php template file: /** @var tpl_home $page */ Now enjoy code completion, etc, in your IDE. Adding data types for non-core Fieldtype modules The module includes the data types returned by all the core Fieldtype modules. If you want to add data types returned by one or more non-core Fieldtype modules then you can hook the AutoTemplateStubs::getReturnTypes() method. For example, in /site/ready.php: // Add data types for some non-core Fieldtype modules $wire->addHookAfter('AutoTemplateStubs::getReturnTypes', function(HookEvent $event) { $extra_types = [ 'FieldtypeDecimal' => 'string', 'FieldtypeLeafletMapMarker' => 'LeafletMapMarker', 'FieldtypeRepeaterMatrix' => 'RepeaterMatrixPageArray', 'FieldtypeTable' => 'TableRows', ]; $event->return = $event->return + $extra_types; }); Credits Inspired by and much credit to the Template Stubs module by mindplay.dk. https://github.com/Toutouwai/AutoTemplateStubs https://modules.processwire.com/modules/auto-template-stubs/
- 39 replies
-
- 16
-
-
-
I have a template that collects pages based on a date search (today). I send that page to a blog (https://wheniwasbuyingyouadrinkwherewereyou.blogspot.com) with php: $to = "xxxx@blogger.com"; $headers = "From: ddv@birthfactdeathcalendar.net\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; When I load the page in my browser it is sent correctly. When I have it sent by a scheduled CRON job (OVH hosting) I get this error: [2026-03-09 10:27:02] ## OVH ## START - 2026-03-09 10:27:02.711006 executing: /usr/local/php8.2/bin/php /homez.863/birthfac/www/site/templates/bfd_mailer.php [2026-03-09 10:27:02] [2026-03-09 10:27:02] [2026-03-09 10:27:02] <center> [2026-03-09 10:27:02] <table width="700"> [2026-03-09 10:27:02] <tr><td> [2026-03-09 10:27:02] <b><span style="font-size: x-large;"><span style="font-family: "Trebuchet MS",sans-serif;"> [2026-03-09 10:27:02] <a href="http://www.birthfactdeathcalendar.net">BIRTH(+)FACT(᙮)DEATH(-)</a></span></span></b> [2026-03-09 10:27:02] <br> [2026-03-09 10:27:02] <span style='font-size: large;'><span style='font-family: Georgia,"Times New Roman",serif;'>41st year - Nº 68 Monday, 9 March 2026</span></span> [2026-03-09 10:27:02] </td></tr> [2026-03-09 10:27:02] <tr><td> [2026-03-09 10:27:02] [2026-03-09 10:27:02] [2026-03-09 10:27:02] ## OVH ## END - 2026-03-09 10:27:02.781779 exitcode: 255 What could be the problem?
-
After reviewing RPB for a long time(and having a few issues) I now decided to use it in projects. But now... problems show up and I don't know how to approach this. Setup: A Onepager, SPA A few RPB fields like rockpagebuilder_events or rockpagebuilder_news ... with blocks assigned. RPB 5.0.3 PW 3.0.229 In this setup I don't need the title field in my blocks, so I sett them all to 'hideTitle' => true It worked. Some time after that I noticed that when adding a new PW page with no RPB blocks, just a simple PW for imprint or privacy ploicy, only the name field shows up, no title field: Even when creating a new template no default title is added. After generating a name and saving the new page no error about the required title is thrown. The page will be created with an empty title! After that the title fie3ld is shown. I commented out //hideTitle => true in a all blocks, but the problem remains. I manually deleted all cached and compiled files and now I am puzzled with this. No additional hooks or anything. Where do I look? What to do? How do I go about this? Could be connected to another problem I will post next.
-
@cwsoft thanks a lot for your help. It turned out to be a bit more complex than what you posted, unfortunately! I'm leaving the full code here, if anyone needs it. // Automatically generate a name for a new race page, // so the user doesn't go throught this step. // It will immediately land on the page editing screen with the page // already created $wire->addHookBefore('ProcessPageAdd::execute', function(HookEvent $event) { $input = wire('input'); $pages = wire('pages'); $session = wire('session'); // Let's generate a random string to append to name and avoid collisions $rand = random_int(0,9) . chr(random_int(97,122)) . random_int(0,9) . chr(random_int(97,122)); // Only when opening the Add New screen (GET request, no form submit yet) if(!$input->requestMethod('GET')) return; $parentID = (int) $input->get('parent_id'); if(!$parentID) return; $parent = $pages->get($parentID); if(!$parent->id) return; // Parent only allows "race" anyway, but let's be explicit $template = wire('templates')->get('race'); if(!$template) return; // Optional safety: only do this when the template is allowed under this parent if(!$parent->template->childTemplates || !in_array($template->id, $parent->template->childTemplates)) return; // Create page $p = new Page(); $p->template = $template; $p->parent = $parent; // Name must be unique + sanitized (prefix avoids numeric-only names) $p->name = 'race-' . time() . '-' . $rand; // Keep it unpublished until user saves/publishes $p->addStatus(Page::statusUnpublished); $pages->save($p); // Redirect straight to edit screen $session->redirect($p->editUrl); // Stop normal ProcessPageAdd rendering $event->replace = true; $event->return = ''; });
-
I’d like to bring attention to a long-standing organizational issue that affects projects with many template files. As projects grow, the /site/templates/ directory becomes cluttered with dozens (or even hundreds) of PHP files, making it difficult to maintain and navigate. The Problem Currently, ProcessWire doesn’t natively support organizing template files into subdirectories. For example, if you want to organize templates like this: /site/templates/ ├── warehouse/ │ ├── dashboard.php │ ├── packing.php │ └── packages.php ├── customer/ │ ├── dashboard.php │ └── packages.php └── sso/ ├── login.php └── callback.php You currently face several challenges: Alternate Template Filename field is unreliable - The admin interface often strips or resets the path when saving, especially if the file doesn’t exist at that exact moment No automatic discovery - You must manually configure each template’s file path Hooks don’t work as expected - Attempts to hook TemplateFile::getFilename or Template::getFilename don’t fire reliably Current Workarounds The existing workarounds are less than ideal: 1. Bridge files as suggested by @LostKobrakai // site/templates/warehouse-dashboard.php <?php namespace ProcessWire; include(__DIR__ . '/warehouse/dashboard.php'); This creates file duplication and maintenance overhead. 2. Manual Alternate Template Filename for each template: - Requires clicking through every template - Path validation often fails - No bulk operations Previous Discussions This has been requested multiple times over the years: Does PW support organizing Template files in sub Dirs? (2016) Template file in other folder than /site/template (2017) How do I organize a lot of templates? (2017) Proposed Solution I’ve opened a GitHub feature request with detailed suggestions: https://github.com/processwire/processwire-requests/issues/575 The core ideas: 1. Path persistence - The Alternate Template Filename field should reliably save paths like folder/filename.php 2. Automatic discovery - If a template named warehouse-dashboard isn’t found, check for /warehouse/dashboard.php 3. Template grouping in admin - Visual organization in Setup → Templates based on folder structure Why This Matters Large projects - Sites with 50+ templates become unmanageable Team development - Clear organization helps multiple developers Module development - Modules could bundle template files cleanly Modern standards - Most frameworks support organized file structures Use Cases This would benefit: Multi-role applications (admin, customer, warehouse staff interfaces) Projects with many page types Module developers who want to bundle templates Anyone with SSO/OAuth files, API endpoints, or admin tools What Can You Do? If you’ve faced this issue or would like this feature: 1. 👍 React to the GitHub issue 2. Share your use cases below 3. Suggest implementation approaches @ryan - Would love to hear your thoughts on this! Is this something that could be considered for a future release? Thanks for reading, and I hope this resonates with others who’ve felt this pain!
- 1 reply
-
- 9
-
-
module StripePaymentLinks – Simple Checkout Integration for ProcessWire
Mikel replied to Mikel's topic in Modules/Plugins
[Update] New Feature: Free Product Access (v 1.0.23) Hi, everyone! We just released v1.0.23 with a new feature based on a real client use case: A client using StripePaymentLinks wanted to grant certain high-value customers bonus access to additional products — no Stripe transaction involved, just a manual override. The solution: a new spl_free_access field (AsmSelect, multi-page) on the user template. Pages selectable in the dropdown are automatically restricted to the configured product templates, so editors only see relevant products — every user in the backend gets a "Free Product Access" field where additional products can be assigned directly. Access granted this way is recognized by hasActiveAccess() — the same internal check SPL uses for all content gating — so it integrates transparently with the existing module logic. The field is created and updated automatically by ensureUserFields(), including template restriction syncing when the product template config changes. Thanks for the request and feedback that led to this improvement! Cheers, Mike -
Hey everyone, I've been building a e-commerce project and needed to show personalized content based on visitor location — shipping availability, regional pricing, state-level compliance notices. Nothing like this existed in the PW ecosystem, so I built it. What it does Detects country, region and city from the visitor IP using MaxMind GeoLite2 databases (free). Result is cached in session. Exposes $geoip as a wire variable — available in every template automatically, just like $page or $user. // That's it. No setup, no require, just use it. if ($geoip->inCountry('US')) { echo $page->us_content; } API // Boolean checks — accept single value or array $geoip->inCountry('US') $geoip->inCountry(['US', 'CA', 'GB']) $geoip->inRegion('GA') // ISO 3166-2 subdivision code $geoip->inRegion(['GA', 'NJ', 'NY']) $geoip->inCity('Atlanta') // Inline conditional with optional fallback echo $geoip->showIf('countryCode', 'US', $page->us_block, $page->global_block); echo $geoip->showIf('regionCode', ['GA', 'NJ', 'NY'], $page->northeast_promo); echo $geoip->showIf('continent', 'Europe', $page->eu_gdpr_notice); // Single field $geoip->getField('countryCode') // "US" $geoip->getField('regionCode') // "GA" $geoip->getField('city') // "Atlanta" $geoip->getField('timezone') // "America/New_York" // Full array $geo = $geoip->detect(); // ip, country, countryCode, continent, region, regionCode, // city, zip, lat, lon, timezone, corrected, status Combining conditions // Country + region if ($geoip->inCountry('US') && $geoip->inRegion('CA')) { echo $page->california_prop65_notice; } // Logged-in + location if ($user->isLoggedIn() && $geoip->inCountry('US')) { echo $page->us_member_block; } // Time-of-day in visitor's timezone $tz = $geoip->getField('timezone') ?: 'UTC'; $hour = (int) (new DateTime('now', new DateTimeZone($tz)))->format('H'); if ($geoip->inCountry('US') && $hour >= 9 && $hour < 17) { echo 'Our US office is open right now.'; } // Pre-select shipping dropdown (Vivino-style) $selectedCountry = $geoip->getField('countryCode') ?: 'US'; $selectedState = $geoip->getField('regionCode') ?: ''; User location correction Frontend widget lets visitors fix incorrectly detected location. Stored per-IP in DB, applied on subsequent requests. You can also build your own UI — just POST to /?geoip_action=correct with country_code, region_code, city. Setup Composer package and databases live in site/assets/GeoIP/ — not in the module directory, so they survive updates. cd /path/to/site/assets/GeoIP/ && composer require geoip2/geoip2 Then drop GeoLite2-City.mmdb (or GeoLite2-Country.mmdb) in the same folder. Free download from maxmind.com. The module config page shows the exact path and command for your server. Admin panel Setup → GeoIP — lookup log with country/region/city, corrections manager, manual IP lookup tool. GitHub: https://github.com/mxmsmnv/GeoIP License: MIT Requires: ProcessWire 3.0.200+, PHP 8.2+ Feedback welcome — especially if you're doing anything geo-based with ProcessWire. Maxim
-
- 12
-
-
Hello y'll, I so happy introduce technical template for ai generate templates on Tailwind from ProcessWire fields. How to work: Select templates you want to design interfaces for Copy the generated JSON structure Ask AI to "Create a Tailwind CSS design for displaying this ProcessWire data" Specify any preferences like: mobile-first, card layout, table layout, etc. Push button "Copy Prompt" Insert prompt to Claude AI, ChatGPT or another ai services. How to Setup: Use ftp for transfer lego.php to template folder On ProcessWire create template with same name. Create new page with select template. Enjoy. Note: It is not always possible to generate a template from the first time, but by debugging you can make even more or less excellent variants. On example screenshot finish page with adjusting elements, blocks on Tailwind. If you have questions or wishes ask me below. Thank you. UPDs: 04/14 Update prompt lego.php
-
Hi, I am trying to collect the page titles of a parent and its children, but this code won;t work: <?php // collect titles for parent + children $titles = [$page->title]; // parent title foreach($page->children as $child) { $titles[] = $child->title; // child titles } // build a selector value like: title="A|B|C" $titleSelector = implode('|', array_unique($titles)); // now find all Championship_results whose winner_name page // has a title matching ANY of those titles, sorted by year descending $champwinx = $pages->find( "template=Championship_results, winner_name.title=$titleSelector, sort=-year" ); ?> It produces this error: any suggestions re a fix appreciated Error: Exception: Unknown Selector operator: '[empty]' -- was your selector value properly escaped? field='G', value='Miss|Temple-Dobell', selector: 'template=Championship_results, winner_name.title=Ravenscroft, G (Miss)|Temple-Dobell, G (Mrs), sort=-year' (in wire/core/Selectors.php line 222)
-
Hey everyone, we just released a small companion module for StripePaymentLinks: 👉 GitHub: https://github.com/frameless-at/StripePlCustomerPortal PW Repo: https://processwire.com/modules/stripe-pl-customer-portal What it does The module auto-creates a ready-to-use page at /account/ where logged-in customers can: view all their purchases (table or grid view) access their purchased products / membership pages update profile data (name + password) open Stripe’s Customer Portal to download invoices or manage subscriptions No custom template coding required — the module installs a template + page, and you can still override the markup if you want. ⸻ Why we built it StripePaymentLinks already handles the checkout & user/purchase creation. This module completes the loop and gives customers a proper account area. 💡 Bonus benefit (Marketing): The grid view not only shows purchased products — it also shows available-but-not-yet-purchased products in greyscale. This turns the account page into a soft upsell area without being salesy. ⸻ Requirements ProcessWire 3.0.210+ StripePaymentLinks module installed & working Stripe Billing Portal must be enabled (Stripe → Settings → Billing → Customer Portal) ⸻ Status 🚧 BETA — already used on live sites, but we’d love developer feedback. If you try it out, please tell us what works and what’s still missing. Issues / PRs welcome. ⸻ Cheers & happy coding, frameless Media
- 2 replies
-
- 12
-
-
-
I've been reading through the forums for best practices on handling images on static pages - that's to say, how best to handle images in my static html markup when I don't have any need for image fields. On my current site, I have a lot of images on the home page and it seems silly creating an image field for all of these. Also, for pages where I do have image fields, I've been using the PageImageSource module to create wepb srcsets automatically (and it works great). I like setting my desired image sizes for the srcsets in one place, so I'd like to use this module for everything everywhere if possible. The problem is that it only works with PageImage objects, so I have to do something with my static images in order for the plugin to work with those. It looks like the media manager modules are not maintained. Could I just somehow put all my non-image field images in one page reference or something and have the PageImageSource module render those wherever they're needed? Could the following work? 1) Create an images/media page and template with images field. Set it to hidden. 2) // In _init.php: $media = $pages->get("template=media", include=hidden); 3) // on a template page markup: $desiredImage = $media->images->get("name=imageName.jpg"); .... <div><=?php $desiredImage->render()?></div> // renders the srcsets and <picture> tags with the PageImageSource module I don't know if this is the recommended way of dealing with <picture> tags for static pages (srcsets are such a pain to do manually!). Maybe there are some downsides to this that I'm not aware of. Any guidance would be very welcome.
- 1 reply
-
- images
- image library
-
(and 3 more)
Tagged with:
-
So I tried the following but I'm not sure if it's good practice or not. Sharing in case anyone finds it useful. This setup requires that the PageImageSource module is installed with srcset image sizes setup in its config. It basically involves creating a page where cross-site images can be uploaded - like a simple image library. I created a short function to make it easier to grab the images where needed. Adding ->render() will output <picture> with srcsets. The media page should be set as hidden. Create a template, give it a name and add a multi-image field In the templates folder create _func.php and add the following: <?php namespace ProcessWire; /* Create a fn. that returns a Pageimage object from media library page you just created. Here i called my function medialib, and $medialibrary is the name of my template.*/ function medialib($filename) { static $medialibrary = null; if (is_null($medialibrary)) { // REPLACE the get directory with the Media Library page url created in admin. Mine was /media-library/ $medialibrary = wire('pages')->get('/media-library/'); } // Returns the image object if found, or null return $medialibrary->id ? $medialibrary->images->get("name=$filename") : null; } Add the include for _func.php in your _init.php in the templates folder: <?php namespace ProcessWire; // This makes the medialib() function available to all templates include_once("./_func.php"); // Render media library images on other pages using format: /*<?= medialib("imagefile.jpg")?->render() ?>*/ Function can now be called in template markup using: // Render media library images on other pages using format: <?= medialib("imagefile.jpg")?->render() ?> //Example <?=medialib("imageNameMustMatchFileName.jpg")->render()?> // Outputs <picture> tag. For CSS styling, target outer div class like so: .class img{.....} Combining this with another module might https://processwire.com/modules/process-media-lister/ might be useful.
- 1 reply
-
- images
- image library
-
(and 3 more)
Tagged with:
-
My personal solution for this issue, without using third party modules, has been: Setup a page reference field on the home template, that lets me pick the projects I want to showcase, and I make the assumption that l'll pick the first image of the gallery of each project. So i the home template you'll end up with something like: <div id="masonry-gallery"> <?php foreach($page->portfolio_pick as $project):?> <img src="<?=$project->gallery->first->url?>"> <?php endforeach ?> </div> - gallery being the field within the project template. - portfolio_pick being the page reference field on the home template. Another thing I've done, but that I'm not a huge fan of for certain uses, is adding a extra fields to the image field, in this example, the field "gallery" in the project template. So you can then code something like this on the home template: <div id="masonry-gallery"> <?php foreach($page->portfolio_pick as $project):?> <img src="<?=$project->gallery->findOne('is_main_image=1')->url?>"> <?php endforeach ?> </div>
- 7 replies
-
- beginner portfolio
- masonry
-
(and 3 more)
Tagged with:
-
Gemini AI Pro is crazy good these days. I was stuck why the replace hook had no effect, and this solved it (courtesy of Gemini from Google is in italic): The reason your hook is firing (as proven by your bd() output) but $p->path, $p->url, and $p->httpUrl are reverting back to the original /parent/ path is due to a hook priority conflict, usually caused by ProcessWire's Multi-Language modules (or an SEO/routing module). Here is exactly what is happening under the hood: Your addHookBefore runs, sets $event->replace = true, and sets $event->return to /blog/. ProcessWire skips its native Page::path() method because of the replace flag. However, another module (like LanguageSupportPageNames) has an addHookAfter attached to Page::path. That module runs after your code, looks at the $page object, recalculates the original path from the database tree, and silently overwrites your $event->return before it finally gets handed back to your $p->url call. To fix this, you need to change your hook to an addHookAfter, remove the replace flag, and bump the priority so your code is the absolute last thing to run. Change your hook to the following: $wire->addHookAfter('Page::path', function (HookEvent $event) { $page = $event->object; if ($page->template == 'original-parent') { // Overwrite whatever the core (or other modules) generated $event->return = "/blog/$page->name/"; } }, ['priority' => 1000]); // Priority > 100 ensures this runs AFTER core modules And yes, I have multilingual support installed, and this solution works.