Jump to content

JoshoB

Members
  • Posts

    115
  • Joined

  • Last visited

Everything posted by JoshoB

  1. Earlier message deleted: I made a mistake with the relative paths -- it all works now, great! Thank you! 🙂
  2. Sorry, wrong thread: I will have a look if I can reverse the order, but I think the problem will be the same, as PW will look for a URL that doesn't exist.
  3. I am also trying to make this work in ready.php to compile Bootstrap on-the-fly, but I get a weird error. Here is the code, adapted from the stuff so kindly shared earlier in the thread, with some modifications to make the file modification checks work (or so I thought): // Define the paths $inputScssPath = $config->paths->templates . "scss/custom.scss"; $bootstrapScssPath = $config->paths->templates . "bootstrap/scss"; $outputCssPath = $config->paths->templates . "styles/bootstrap_custom.css"; $outputMapPath = $config->paths->templates . "styles/bootstrap_custom.map"; // Check if the output CSS file exists and if any SCSS file has been modified $recompileRequired = !file_exists($outputCssPath); if (!$recompileRequired) { $outputCssMTime = filemtime($outputCssPath); $recompileRequired = false; // Find all .scss files in the /scss/ folder $watchFiles = $files->find( $config->paths->templates . "scss", ['extensions' => 'scss'] ); foreach ($watchFiles as $watchFile) { if (filemtime($watchFile) > $outputCssMTime) { $recompileRequired = true; break; } } } // Compile SCSS if recompilation is required if ($recompileRequired) { $scss = $modules->get('Scss'); $compiler = $modules->get('Scss')->compiler; if($compiler) die("Found module."); else die("Module not found!"); $compiler->setSourceMap($compiler::SOURCE_MAP_FILE); $compiler->setSourceMapOptions([ 'sourceMapURL' => $outputMapPath, 'sourceMapFilename' => $outputCssPath, 'sourceMapBasepath' => $config->paths->root, 'sourceRoot' => '/', ]); $compiler->addImportPath($bootstrapScssPath); $compiler->setOutputStyle("compressed"); // Get the result $result = $compiler->compileString('@import "'.$inputScssPath.'";', $config->paths->templates . "scss"); // Save the output in the proper files file_put_contents($outputMapPath, $result->getSourceMap()); file_put_contents($outputCssPath, $result->getCss()); } It kept giving me a fatal error at the line with $compiler->setSourceMap($compiler::SOURCE_MAP_FILE); (complains about NULL), so I added the check with the die statements: it cannot find the compiler for some reason. But if I change if($compiler) to if($scss) -- I added $scss for testing purposes -- it finds the latter just fine. Any idea what I am doing wrong here?
  4. I was using this to share early access to articles with Patreon users. However, Patreon now filters query strings from URLs, which is a PITA. I wanted to rework this module to use URL segments, so that any URL that ends in /preview/ becomes a preview link, but no dice: ProcessWire throws a 404 every time, regardless of what I try. Any suggestions or ideas? Thanks again. 🙂
  5. I am looking for an ecommerce solution with ProcessWire and this seems to fit the bill. Supporting the latest version of SnipCart and enforcing use of PHP 8 are both fine, I think.
  6. Still working on my CRM... I need to send emails with attachment. I am using the WireMailPHPMailer module. Everything seems to work fine, but sending an attachment doesn't work. The attachments are selected on the form from pages. Each of those page features a file field (called just "file") with a file, usually a PDF. In the e-mail form, I enter the sender, the addressee, the subject, the message, and then I select, from a dropdown, the attachment I want to attach to this message. However, clicking "send" will send the e-mail, but without an attachment. I think this code will make it more clear ($formAttachment is the ID that gets sent as a $_GET variable when the form is submitted, and "file" is the field that contains the selected file in question): $file = $pages->get("id=$formAttachment")->file; $mail->addAttachment($file->path, $file->name); Going step by step through the code, the error ProcessWire throws up is "Could not access file". I have been banging my head against this now for a week, so I am hoping that someone here can have a look and say, "Oh hey, you need to do this and it's fine." I am pretty sure it has to do with either permissions in the file structure (this is a file that gets upload to /assets/ for the page in question), or that my understanding of ProcessWire's "path" is completely off. Either way, any help would be greatly appreciated!
  7. Oh, cheers! I think I managed to solve it thanks to that thread. For posterity/future reference, this is what I wrote in the parent template: // Populate history_repeater with history from underlying pages, too foreach($page->children() as $child) { $page->history_repeater->add($child->history_repeater); } $page->history_repeater = $page->history_repeater->find("sort=-datetime");
  8. I am building a website that serves as a client management system. I have organisations (each a page) and they are parent pages to contacts (i.e. people). Both the organisations and the contacts beneath them have a repeater field, "history_repeater", that is used to store comments in. The repeaters consist of a date/time field ("datetime") and a comment field ("comment"). An organisation page should show the complete history for that organisation, i.e. add the "history_repeater" data from the underlying pages (contacts) to the main "history_repeater" field in the organisation page, and then reverse sort the results by "datetime". I cannot seem to figure out how to do this in a neat way without taking recourse to building an array. I think it should be doable with a simple selector and sort, but how escapes me at present. Does anyone have a solution for this? Thank you so much in advance.
  9. Edit (complete wipe of original message): I couldn't get this to function, so I've changed how I handled my authors to clean up the users for comments etc. This means I'm using the original database/install instead of a separate one for comments.
  10. Thanks everyone, this has all been really helpful!
  11. Excellent. What would be the best way to connect to the second database/website? Should I make another wire instance? I feel like it should be simple.
  12. Oh yeah, I am familiar with the database structure. I should have added that I want people to be signed in before they're allowed to post comments, so the website would see an influx of users. Currently, all "users" on the website are authors who write articles, and I would like to keep this list as small as possible. (I know I can use roles to manage the lists, but I would prefer a simpler solution.) There's also the issue of security: I don't want there to be any risk that a user is able to mess anything up, and I'd prefer to keep them out of the main database.
  13. Hello everyone, I manage a large site and would like to add the ability for visitors to add comments to articles. However, I also want to keep the core website database relatively "clean". So my idea was to install a fresh copy of ProcessWire to a subdomain (say, account.ancientworldmagazine.com), where users can register, sign in, and edit their profile. I could also sign in and manage comments. My idea is to load the new database into the website, so that a page can check if there's any pages with comments in the new database. So, for example, article X on my original website gets loaded, there's an if-statement that checks if there's a page in the new database with the field awm_page_id = $page->id (where $page is the article on the original website). If yes, it proceeds to load the comments from that database; if no, it creates a new page with the field awm_page_id = $page->id and people who are signed in can then start posting comments. So, is this feasible? Does it pose any security risks? Will it create unnecessary overhead and slow everything down? Am I better off just sacrificing the cleanliness of my website's database and enabling comments on there directly from the backend? I'd love to hear your thoughts.
  14. So I've been using FormBuilder on client websites, but now they want to be able to track the form output using Google Analytics. I have no idea how they should go about this. Any suggestions that I could pass onto them? Thank you very much!
  15. Wow, that is perfect! You should add it to the module repository. Thank you so much!
  16. I'm testing it by putting the code in init.php (which gets loaded first), then going to the page in question via another browser with ?preview=true, and I get a 404 page instead of the article I want to preview. But maybe forcing the 404 page to reload would be an idea. (Even though I cannot get that to work either.)
  17. I upgraded to the latest version of PW, but no dice. Doesn't work, with or without slash. I also have AIOM installed -- could that be a problem?
  18. Thank you for the suggestion, but it doesn't work: I still get a 404 error, even when I put it in site/init.php.
  19. So I'm the editor of a large website and it's useful for me if my authors can check their articles before they are published on the web. I'd prefer to do this without needing them to sign in (with either their own account or a preview account). I figured the easiest way to do this is with a GET variable, so if someone goes to e.g. this URL: https://www.examples.com/articles/test?preview=true They would be able to see the specific article in question. But building the override eludes me; I tried to stick it in the template, but it's not working (using $pages->find or $pages->get with check_access=0). I feel like this ought to be simple, but I cannot figure it out. Does anyone have a suggestion on how to solve this? Many thanks in advance, as always!
  20. Cheers @Autofahrn, that put me on the right track. {$page->children} didn't work as expected, but in the PHP file in question, I did loop through all categories to generate a clickable list, so I simply populated $pageSelect with the ID of every item as it looped through them. I then fed the variable into the selector and that did the trick! Thanks again for the help, everyone.
  21. This looks like it ought to work! Sadly, it doesn't. $page->children doesn't seem to do anything (the results get dropped).
  22. Weird, it generates an error: Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? has_parent is apparently not valid as a subfield selector.
  23. Ah yeah, sorry. That is correct: $page in this instance has a category.php template. Your solution sadly generated an error. I edited it to read: "template=product, limit=10, categories=[has_parent|id=".$page->id."], sort=categories.sort, sort=$sort_results" But then it doesn't list any products. I think that's because it now specifies it has to either have a parent or the ID needs to be specifically that of the page. What I'd like to do is to specify that the categories field includes either the current $page or one of the current page's children (i.e. the subcategories). So I was hoping something like this might work: categories.parent=$page|$page->children But no dice.
×
×
  • Create New...