Jump to content

Jan Romero

  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Jan Romero

  1. Hi, I tried to reproduce this without success (3.0.208 dev). Can you share more about your setup?
  2. This helped me give in to my nagging coworkers and sign up for ChatGPT, but I can’t seem to get it to answer this question properly? May I ask what your prompt was, @Jonathan Lahijani? Also, what’s causing problems with calling ready() explicitly?
  3. Looking good, however I can’t access it from Germany (connection times out) :O
  4. It’s handled, but I wasn’t able to send a 200 status unless allowing the $ in .htaccess. I don’t know what’s going on there, I imagine it’s overridden by Apache after PW is done. Other status codes worked for me, though. Only 200 always turned into 404.
  5. I tried to replicate this problem and it turns out there are some characters you can add to $config->pageNameWhitelist and .htaccess all you want, this blacklist in the core won’t have it: https://github.com/processwire/processwire/blob/master/wire/core/Sanitizer.php#L911 Dollar signs are FORBIDDEN!!!! However, don’t despair yet, you’re never more than a finite amount of disgusting hacks away from success: wire()->addHookBefore('ProcessPageView::pageNotFound', function(HookEvent $event) { if (stripos($_SERVER['REQUEST_URI'], '/concepts/') === 0) { //serve file } }); This needs to go into init.php and runs whenever PW would otherwise 404, that is, it can’t find a page or url segments or url hooks for the requested path. Some things will not work as expected in this hook. For example input() will not be populated. To make the $ work you’ll need to update your .htaccess, though. For example you can just add the $ to the default rewrite condition: # PW-PAGENAME # ----------------------------------------------------------------------------------------------- # 16A. Ensure that the URL follows the name-format specification required by PW # See also directive 16b below, you should choose and use either 16a or 16b. # ----------------------------------------------------------------------------------------------- RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/\$]*$" # ----------------------------------------------------------------------------------------------- # 16B. Alternative name-format specification for UTF8 page name support. (O) # If used, comment out section 16a above and uncomment the directive below. If you have updated # your $config->pageNameWhitelist make the characters below consistent with that. # ----------------------------------------------------------------------------------------------- # RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$" Or use the other one below and add it there. Or do whatever is applicable for nginx? Not ideal but still better than messing with the core, I guess.
  6. If you want to modify the Module you could replace the original switch case in FieldtypeTable.module with this: case 'text': $maxLength = empty($col['settings']['maxLength']) ? 2048 : (int) $col['settings']['maxLength']; $stripTags = empty($col['settings']['stripTags']) ? true : ($col['settings']['stripTags'] === 'false' ? false : true); $v = strlen("$v") ? $sanitizer->text($v, array('maxLength' => $maxLength, 'stripTags' => $stripTags)) : null; break; That will allow you to specify stripTags=false on text colums.
  7. Unfortunately I believe this is hardcoded behaviour (see _sanitizeValue() in FieldtypeTable.module). As you noticed, it doesn’t strip tags from textareas, so maybe switch to that? It should be quick work to add this as a per-column option like maxLength. Perhaps worth suggesting it to Ryan in the ProFields forum?
  8. Btw, it should be possible to create a new page with a string template name using $this->pages->newPage() https://processwire.com/api/ref/pages/new-page/
  9. You can change the dpi in Document -> Resize Document by unchecking “Resample”, i.e. you’re just changing how big the image should appear on physical media but not its pixel dimensions: For example here’s a 300px by 300px picture of a salad. Both images are exactly the same, but if you import them into a DTP software like Affinity Publisher, InDesign or Scribus, by default one will be 8cm (96 dpi) and one will be 2.5cm (300 dpi). That is to say you’re correct and dpi don’t matter in terms of file size or pixel resolution on the web.
  10. Yes, that is the way. What are the contents of your DefaultPage.php file? https://processwire.com/blog/posts/pw-3.0.152/#new-ability-to-specify-custom-page-classes If you just want to add a method or property you can also use hooks for that: https://processwire.com/docs/modules/hooks/#how-can-i-add-a-new-method-via-a-hook
  11. @gnarly Thanks, I added it to the post 🙂 Welcome to the forums!
  12. I suspect this shouldn’t be too hard to implement naively, but it’s probably non-trivial to get all the configurable bells and whistles to work that image fields support (like client side resizing for example). I think you can grab images from the clipboard as blobs by listening to the paste event and filtering by type pretty easily. You’d have to figure out which image field to use, since a page could have multiple, and how to interface with it. I agree CTRL+Ving images is delightful and a desirable feature to have! Personally I don’t like WYSIWYG editors, so a cool feature would be the ability to paste pics into a Markdown textarea and have it upload it and generate the code automatically, like we see on Github.
  13. ProcessWire is particular about the difference between saving pages and saving individual fields. In this case, only Pages::save and Pages::delete trigger the hook: https://github.com/processwire/processwire/blob/master/wire/modules/PageRender.module#L74. I agree this difference is pretty underdocumented. You can probably hook up your desired behaviour somewhat like this in ready.php: $this->addHookAfter("Pages::saveField", function(HookEvent $event) { modules()->get('PageRender')->clearCacheFile($event); }); I haven’t tested it but the relevant hook arguments should be the same, i. e. the Page is argument 0, so it might work? There is also Pages::savedPageOrField for when you want to make your own hooks trigger regardless of how the page was modified.
  14. Try checking them since they DISable appended files. Also check your config file for “appendTemplateFile”: https://processwire.com/api/ref/config/#pwapi-methods-template-files
  15. Does this not work equivalently for file fields?
  16. date - Documentation - Twig - The flexible, fast, and secure PHP template engine Says here you can change Twig’s default date format like this: $twig = new \Twig\Environment($loader); $twig->getExtension(\Twig\Extension\CoreExtension::class)->setDateFormat('d/m/Y', '%d giorni'); And format individual expressions like this: {{ page.created|date("d/m/Y") }} But to get Italian words like ”giugno“ or “venerdi” you’ll probably need something called “Twig Intl Extension”: https://stackoverflow.com/a/75572704
  17. This is how I do it: http_response_code(200); But 200 is the default anyway. It should always be sent unless you change it or an exception happens. I think @Denis Schultz may be on to something with the Content-Type header?
  18. Robin’s suggestion of using a custom page class should work for that, just override get(): <?php namespace ProcessWire; class DefaultPage extends Page { private $cache = [ 'title' => 'look at me. i’m the title now.' ]; public function get($key) { return $this->cache[$key] ?? parent::get($key); } } IRL you may want to add logic dealing with output formatting and what not, but that should be a complete working example. Unfortunately get() is not hookable, so I don’t believe this can be accomplished in a module. That said, have you investigated other avenues? Why not cache the whole markup and be done with it?
  19. Maybe you can hook Fieldtype::loadPageField()? https://github.com/processwire/processwire/blob/6ff498f503db118d5b6c190b35bd937b38b80a77/wire/core/Fieldtype.php#L1108
  20. There is a setting for url fields to allow or disallow quotation marks. I’m pretty sure it defaults to disallowing them. Have you checked that?
  21. I see. I suppose the easiest way would be to just nest a single array in $vars and only ever use that. A more generic solution could involve hooking before TemplateFile::render: https://github.com/processwire/processwire/blob/6ff498f503db118d5b6c190b35bd937b38b80a77/wire/core/TemplateFile.php#L305 You could add something like $this->addHookBefore('TemplateFile::render', function(HookEvent $e) { $tpl = $e->object; $tpl->data('passedVars', array_diff_key($tpl->getArray(), wire()->fuel->getArray())); }); That should make the passed variables available as usual and additionally inside an array called $passedVars. I don’t think you’re going to get around the whole array_diff_key business at that point, unfortunately? The way passing vars to a file works in the core seems to immediately conflate those vars with the general globals. It happens even before render() is called, for instance here: https://github.com/processwire/processwire/blob/6ff498f503db118d5b6c190b35bd937b38b80a77/wire/core/WireFileTools.php#L1478.
  22. It’s not going to be in $vars. Instead, every key of the dictionary becomes a global variable, so psy’s example would introduce the variables $items, $homepage and $category to your template file.
  23. Hi @mackpatrick, welcome to the PW forums! Profields Table supports files and images since August 2022/version 23:
  • Create New...