-
Posts
680 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Jan Romero
-
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: -
https://news.ycombinator.com/item?id=35659963 which one of you is this? ?
-
Hook before ProcessLogin::execute not working
Jan Romero replied to Sandy's topic in API & Templates
Unfortunately I have nothing to contribute, but I tested your exact code on a PW 3.0.183 installation of mine and it worked as expected, so maybe the problem lies somewhere else? -
@zoeck you’re right, disregard everything I’ve said in this thread. It appears I have bought too many ProFields for myself ?
-
Yeah, but you can only renew for that price continuously. If you let the year elapse you have to pay full price to get another year, although I believe Ryan has made individual exceptions to this. At least that’s my understanding. IIRC the renew button is only there during the support period.
-
No, afaik that’s the way. I think it’s a fair enough deal. It definitely is for commercial use while still being somewhat affordable even for hobbyists. I mean, it’s a lifetime license for unlimited sites and the ProFields are awesome, you can’t go wrong with that. You can also get the “subscription” where you pay a heavily discounted yearly renewal. Or you could try asking Ryan nicely ?
-
[SOLVED] How do I format the username displayed on the admin?
Jan Romero replied to Boost's topic in General Support
Go to Modules -> Configure -> AdminThemeUiKit. There will be a section called “Masthead + navigation” which you can click to open. Then under “User navigation label format”, where it currently says “{Name}”, enter “{title}” instead. Or any other valid template string you like, obviously. The field pretty much tells you what to do. Of course this only works if your user template has fields for the things you want to display. As you will notice, other admin themes have their own settings, so if you allow users to change themes, you’ll probably want to make equivalent changes to all of them. However, AdminThemeReno doesn’t use the same template string system and AdminThemeDefault has no setting for this at all. -
Long time no WillyC! Also, I agree.
-
You can find the name of the admin by looking at the page with ID 2 in the database. Since you have access to the filesystem, you can also just echo $config->urls->admin somewhere. To reset the admin password, put this into a template and execute it: $u = $users->get(41); $u->of(false); $u->pass = 'hunter2'; $u->save(); 41 is usually the superuser who installed the site. If it isn’t you can try to find the account by selecting one with the role “superuser”.
-
HTMX will see the hx- attributes on your element and send a GET request to yourdomain.at/trigger_delay with the value of the input named “q” whenever it is triggered. Whatever the server sends as a response, HTMX will put in the div at the bottom (HTMX calls this “swapping“). Or something like that. I’m not familiar enough with HTMX’s defaults and the trigger syntax to be sure that your code will definitely work. Looks good though. The important parts happen in /trigger_delay, obviously. That is in keeping with HTMX’s whole raison d’être of mostly sticking to doing things on the server. What’s sticking out to me is the url of your endpoint “/trigger_delay”. It looks like this is supposed to be a page that returns search results or type-ahead suggestions, so I would expect something like “/search”.
-
How to force trailing slash on url segments?
Jan Romero replied to bernhard's topic in General Support
There is this setting, but I’m not sure whether it will redirect or 404 if the undesired option is requested.