-
Posts
612 -
Joined
-
Last visited
-
Days Won
15
Everything posted by Jan Romero
-
Yikes! - URL Segment Bypasses Template Access Control
Jan Romero replied to Jim Bailie's topic in General Support
Hi, I tried to reproduce this without success (3.0.208 dev). Can you share more about your setup? -
Looking good, however I can’t access it from Germany (connection times out) :O
-
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.
-
Pro Fields Table: HTML being removed from text field
Jan Romero replied to DrQuincy's topic in General Support
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. -
Pro Fields Table: HTML being removed from text field
Jan Romero replied to DrQuincy's topic in General Support
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? -
Creating a new page from a class file fails
Jan Romero replied to Inxentas's topic in General Support
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/ -
[SOLVED] How to prevent users from uploading 300 dpi images?
Jan Romero replied to howdytom's topic in API & Templates
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. -
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
-
A tricky selector based on a parent page's checkbox
Jan Romero replied to heldercervantes's topic in General Support
(nvm) -
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.
-
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.
- 1 reply
-
- 4
-
Why is this 👇 showing on an empty template file
Jan Romero replied to eutervogel's topic in General Support
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 -
Does this not work equivalently for file fields?
-
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
-
How to send Success 200 response to sender in webhook?
Jan Romero replied to psy's topic in General Support
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? -
How to track all called $page->* properties (fields) ?
Jan Romero replied to ukyo's topic in General Support
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? -
How to track all called $page->* properties (fields) ?
Jan Romero replied to ukyo's topic in General Support
Maybe you can hook Fieldtype::loadPageField()? https://github.com/processwire/processwire/blob/6ff498f503db118d5b6c190b35bd937b38b80a77/wire/core/Fieldtype.php#L1108 -
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?
-
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.
-
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.
-
ProTable doesn't support images or files?
Jan Romero replied to mackpatrick's topic in General Support
Hi @mackpatrick, welcome to the PW forums! Profields Table supports files and images since August 2022/version 23: