Jump to content

TwoWheelDev

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by TwoWheelDev

  1. Whenever I'm setting up websites, I've always gone down the route of just manually configuring nginx, and copying the files to the webroot (including for ProcessWire). My only real experience with docker has been for running stuff locally during development (originally docker-compose but as of today DDEV), so my question is does anyone run their site using docker, in particular PW. As all my sites I host are small, low-traffic sites I just have them running on a small VPS from DigitalOcean - with manually configured XEMP, and I've always struggled to see what benefits a docker/container-based approach would give. One thing that's always worried me with a docker based approach is for things like the DB, ensuring that if the container is destroyed the DB data isn't lost! It seems most of the tutorials in the wild are more geared towards using hosted databases... but when you're on a budget every cost adds up!
  2. Not sure, the ajax parts are actually not so much frontend pages, as just small updates (mostly around the cart system) which all has to tie-in quite closely with the module I'm building to work with a dropshipping printing api
  3. Time to answer my own question... and love it or hate it AI came up with the goods on this one! Defining the urlHook as follows: public function init() { $this->addHook('/custom-url/', $this, 'handleCustomURL'); } And the handleCustomURL function (this was the second iteration I got for this to include having a default template in the module, whilst allowing them to be overridden in the site/templates/ folder): public function handleCustomURL(HookEvent $event) { // Path to the override template in the site's templates directory $overrideTemplatePath = $this->config->paths->templates . 'custom-template.php'; // Path to the default template in the module's directory $defaultTemplatePath = $this->config->paths->siteModules . $this->className() . '/templates/custom-template.php'; // Determine which template to use $templatePath = file_exists($overrideTemplatePath) ? $overrideTemplatePath : $defaultTemplatePath; // Check if the determined template exists (for safety) if (!file_exists($templatePath)) { throw new Wire404Exception("Template not found"); } // Render the template and pass variables $output = $this->files->render($templatePath, [ 'someVariable' => 'someValue', // Add additional data if needed ]); // Output the rendered content echo $output; // Stop further processing $event->replace = true; } I did make a small to change to the end of the function as follows: // Output the rendered content //echo $output; return $output; // Stop further processing - Doesn't look like this is needed! // $event->replace = true; } Not sure any amount of Google-Fu would have got me to this, so it's interesting to see how AI can pull the correct bits of information together! I have obviously tested the above code, and it seems to work a treat!
  4. So I've got the URL Hooks working wonderfully! makes it really easy to create some custom logic to handle things At the moment, I'm using a mixture of urlSegments (for one route e.g. /shop) and urlHooks (for the backend json stuff at /api/<stuff here>). Is it possible to use the urlHooks to create a something similar to the urlSegments. I see in the documentation you can return a page, but is it possible to create the hooks function that would get a template and do the necessary before returning that to the user? I guess something similar to the way the an admin module can use views for the pages, and the function just pushes the data into that page. Hopefully that makes sense! 🤔
  5. Oh, that's awesome! Exactly what I was looking for! And thank you! Been registered here ages... but only just needed to actually post, such is the amount of awesome information already out there fro ProcessWire
  6. I'm in the process of developing a module, that will need to handle callbacks from the third-party API. The pages for the callback will need to be accessible from frontend without a login, what's the best way to handle this from a module. Is it possible to do without manually creating the pages... I guess some sort of registering a URL that processwire will send to the module to do the processing
×
×
  • Create New...