-
Posts
63 -
Joined
-
Last visited
Everything posted by VeiJari
-
How to detect if a template form has errors in it?
VeiJari replied to VeiJari's topic in API & Templates
It seems my question is too confusing? ? -
Hello forum, this is my first security related post, so I'm a bit of a newbie. I understand that when I have direct front-input from user I should sanitize the input, but how about when I use a secret key for showing a API for a third-party supplier? Should I sanitize the input->get() key? I've tested this issue and I tried ?key=<?php echo $page->field; ?> And without adding any sanitization it comes back: /?key=<?php%20echo%20$page->field;%20?> So can I rely on this, or should I still use $sanitizer just in case? Thanks for the help!
- 4 replies
-
- security
- injections
-
(and 2 more)
Tagged with:
-
Updated to the latest version and also you fixed the items url's not including the rooturl, cheers for that! Now I can also translate without problems, thank you for correcting errors in such a short notice! +1 recommendation for this mod.
-
Upgraded to the latest version and warnings disappeared. I also noticed that you have to manually add the search_index field to the templates you want to index. I assumed it would automatically add them to the templates you want to index. It could be handy, but not a deal breaker to the honest. Now I got it working, thanks for your help! The next step is to translate the texts. I tried to do it via language, but nothing changed? So there's no translate support yet?
-
@teppo First I would like to thank you for creating this module! However, I'm having problems with it. When I try to index my fields I get two warnings: Warning: Declaration of SearchEngine\Renderer::__get(string $name) should be compatible with ProcessWire\Wire::__get($name) in xxx/modules/SearchEngine/lib/Renderer.php on line 581Warning: Declaration of SearchEngine\Query::__get(string $name) should be compatible with ProcessWire\Wire::__get($name) in xxx/modules/SearchEngine/lib/Query.php on line 226 Then it says "indexed 0 pages in 0 seconds". Why does it do that? Thank you.
-
How to setup Composer and use external libraries in ProcessWire
VeiJari replied to MoritzLost's topic in Tutorials
require './vendor/autoload.php'; this did the trick, when I desperately changed the folder name. Thanks for you help! -
How to setup Composer and use external libraries in ProcessWire
VeiJari replied to MoritzLost's topic in Tutorials
@MoritzLost Thanks for the tutorial! I just have a major problem and I don't have a clue why this happens. in site/config.php when i try to require the path to my autoload.php: require '../../libraries/vendor/autoload.php'; autoload is located at: websitex/libraries/vendor/autoload.php Everything is white, every single page. I assume I'm getting some error on this instance, but I can't check it anywhere. When I comment it out, everything works (except the library I'm trying to use in the first place) What should I do? -
Page Hit Counter – Simple Page View Tracking
VeiJari replied to David Karich's topic in Modules/Plugins
@David Karich Very useful module, works like a charm! I was just wondering if there could be a way to call the resetPageViews from a template file? I would find it more valuable if there's an option to reset templates' page hit counter from the template itself. That way, we don't have to give access to the module settings for the average user to reset page hits. I've tried to use it, but it seems that the module itself doesn't have a clue about the modules' methods. If this is something that Processwire doesn't process, someone could point out that for me :D Thank you!- 111 replies
-
- hitcounter
- tracking
- (and 4 more)
-
Hello forum. I'm trying to figure out how to detect if current form has errors after saving it in pw admin page. This is so that our event location isn't added in database if we detect errors. But I can't seem to find a correct way to detect errors? I only found the wire()->errors() and it always triggers even if I don't have any errors. How can I detect errors in a form? By error I mean $page->error('this is the red error');
-
Ah thank you for this. It was a bit weird for having to reinit it ?
-
Hello forum! Our customer wants to choose only 15 minute intervals in the inputfield Datetime. So the dropdown values would be: 0, 15, 30 and 45. Is there an easy way to achieve this? Any help is appreciated ?
-
How to programmatically change page name after saving it?
VeiJari replied to VeiJari's topic in API & Templates
Ah, silly me ? Of course I didn't think the obvious. It now works and I'm using this module: https://modules.processwire.com/modules/page-rename-options/ for all the pages at the moment! Thanks anyway! Ah I see! Good to know, might be handy someday for preventing those pesty infinite loops ? Thanks horst -
Hello forum! I've yet again stumbled on a head-scratching situation. We have enabled the option on our articles template and events template that it skips the title adding part and goes straight to the form. This is what our customer wants. So when you add a new article or event it automatically names it temporary to "article-0000000" and same with event. Now the problem is that obviously after saving the form we want to change to page url or "name" to the title, like it's normally. Now here's the code for the hook: wire()->addHookBefore("Pages::saved(template=tapahtuma|artikkeli)", function($hook) { $page = $hook->arguments(0); $newUrl = wire()->sanitizer->pageName($page->title); // give it a name used in the url for the page wire()->log->message($page->name); $page->setAndSave('name', $newUrl); }); I get the correct page and the name and path changes when I log them, but when I try to save it. It just loads and then I get: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) This happens in sanitizer.php and then another error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0 What is happening? Am I not suppose to use sanitizer in this way? When we made a temporary page object in out other hook, the sanitizer worked perfectly. Thanks for the help!
-
Found out the solution myself, thank you!
-
Ah, that explains it. Thank you for clarifying it! Now it works ? This was also the problem, didn't know there was such a file! Thank you.
-
Checking if template is a temporary template before saving
VeiJari replied to VeiJari's topic in Getting Started
@Zeka In template settings advanced "Tila" means status so I'm referring to this "temp unpublished" status. -
Checking if template is a temporary template before saving
VeiJari posted a topic in Getting Started
Hello, our customer doesn't like the fact that they have to first add a title and then add the other info in the form. Therefore, we've enabled the way to skip this by making a temporary file before saving. But the problem is that by using module schedulepages in this piece of code in the module: if (!$page->isNew() && $page->publishable() && $page->isChanged('status') && $page->is(Page::statusUnpublished) && $page->publish_from) { $this->session->error($this->_("“Publish From Date” field was cleared to prevent the page from being unintentionally re-published on the next Lazy Cron run.")); $page->publish_from = null; $page->save('publish_from'); } it fires even with the temporary file and therefore after first save it resets the publish_from field. Is there a way to check if template is temporary, or something along those lines? One solution is just to ask the customer to first save the form after adding a title, but I don't see that as a good solution. -
Yes I've enabled debug mode and my other hooks are starting with $wire->addHookAfter...
-
And for a site note I'm using schedulepages module, which uses lazyCron at it works perfectly.
-
Hello forum! I'm trying to learn how to time up my functions by using lazycron but I can't get it fired up. Here's my code in site/init.php: function setEventToRepeat(HookEvent $e) { $wire->log->message("kutsutaan cron"); $events = $wire->pages->find('template=tapahtuma'); die(var_dump($events)); $wire->log->message('Kaikki tapahtumat haettu:' .$events); } $wire->addHook('LazyCron::every30Seconds', null, 'setEventToRepeat'); I get nothing in the logs and can't echo or dump anything Thanks for the help!
-
Works like a charm! Thank you for this! And also, I want to thank every one for motivating me to write hooks and seeing how practical and easy they're to make! ?
-
I think the solution lies somewhere in that topic, but I haven't figured out how to integrate Robin S' solution for my Pages::published hook.
-
I was actually talking about /site/templates/_init.php, but after reading the difference of /site/init.php and /site/templates/_init.php, I decided to include psys' solution to site/init.php. Thank you for this!
-
Tested and the code works! Thank you for this. Our customer also wants the field to be disabled when the page is published, how do you achieve this? Quick browsing of the API, there doesn't seem to be a disable() function for a field.
-
Hello forum! I started to write my first hook for Processwire but I'm pretty confused how you should write these. My idea is to hook after publishing in init.php (called before templates) for a certain template. Here's the code: Trying to reset the checkbox (ajasta) and then saving it so it shows unchecked in the admin page when publishing "article" page. But the code isn't doing anything. Not even dumping anything What seems to be the problem? And have you made a similar hook for this usage or am I doing it totally wrong? ? Thanks for the support in advance!