-
Posts
1,407 -
Joined
-
Last visited
-
Days Won
17
Everything posted by Juergen
-
I have installed it again but now I have only included the module in the blackhole.php (not on the home or other page) only to see if it works. It works now, but the loading time of the page is approx. 21 seconds!!!! I have added a hidden link in my site to the blackhole.php and if I click on it my IP will be stored in the DAT file - works well. In the mail that I got afterwards there was a hint about a Port problem: Whois Lookup: Timed-out connecting to $server (port 43). I am on a shared host so it seems that this port is not free. The strange thing is that I have disabled the Who is Lookup in my settings of the module Best regards Jürgen
- 35 replies
-
- 1
-
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
Hello @ all, I have no idea, but approval via email does not work in my case. Here are all my get variables that will be submitted by clicking the link in the email: code gKB6jlhWTowUeahUNX6OWWvBYBxYf1D41I5LZb4ws1YsA73jmk7sQeOoU1QAy4L6f1IAnmaSKXRjINOtGFDKO92e10Y5IuTzmuHOwkGI8bWtcXaIGstDB_xzq9hhwvZx comment_success approve field comments page_id 2006 As you can see all parameters are there. As far as I know the file CommentNotifications.php is responsible to save the new status "approved" after clicking the link, but in my case nothing changes and I do not get any message on the frontend. Tracy does not complain about anything so I dont know how to check where the problem is. Is there someone who could give me a hint to check out whats going on after clicking the link to find out the problem. Best regards EDIT: Ok, I see! This doesnt work if the comments were not rendered with the render function. So using your own markup to output comments inside a foreach prevents the status change after clicking the approval link. Solution: Copy the whole Fieldtype comments directory in site/modules and make all the markup changes there. Load comment form and list via the render function and everything is fine.
-
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
Juergen replied to David Karich's topic in Modules/Plugins
Strange, after clearing the module cache it works now -
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
Juergen replied to David Karich's topic in Modules/Plugins
I have tried it with several combinations and also with absolute pathes - no difference. -
Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML
Juergen replied to David Karich's topic in Modules/Plugins
Hello @all I have a problem with integrating external stylesheets into AIOM. I have toggled the checkbox to allow stylesheets from outside the template folder, but I always get the following message: PHP Warning: file_get_contents(): Filename cannot be empty in .../site/modules/AllInOneMinify/AllInOneMinify.module:596 So it doesnt find the external stylesheet wich is located in /node_modules/cookieconsent/build/cookieconsent.min.css. This is how I have tried to integrate it: $stylesheets = [ '/node_modules/cookieconsent/build/cookieconsent.min.css', 'css/main.less' ]; echo '<link rel="stylesheet" href="'.\AIOM::CSS($stylesheets).'">' . "\n"; Independent if I change the path to /node_modules/cookieconsent/build/cookieconsent.min.css or ./node_modules/cookieconsent/build/cookieconsent.min.css or ../node_modules/cookieconsent/build/cookieconsent.min.css there is no difference. Technical data: AIOM 3.2.3 PHP 7 PW latest dev Is there something else I am missing? -
Great! I didnt know that this exist
-
Is there a way to combine hooks to reduce the code
Juergen replied to Juergen's topic in API & Templates
In my case I want to count the children which are under the current page beeing edited. Each child page is a date, so I count of how many dates this page has. But counting the children via siblings could also be an opportunity. -
Is there a way to combine hooks to reduce the code
Juergen replied to Juergen's topic in API & Templates
Here is my code for others who also deals with the same issue. This little function prevents the deletion of the last child page if page has a certain template. Code runs inside ready.php. //prevent deletion of last child function wire()->addHookBefore('Pages::trash', null, 'preventdeletionlastevent'); wire()->addHookBefore('Pages::delete', null, 'preventdeletionlastevent'); function preventdeletionlastevent($event) { $page = $event->arguments(0); if(!in_array($page->template->name, ['single-date', 'single-event', 'single-business-vacation', 'single-special-business-hours'])) return; $parent = $page->parent; $childrennumber = count($page->parent->children); if($childrennumber === 1) { $event->replace = true; // now original function won't be called $event->return = wire()->warning(__("Deleting of the last date is not allowed. There must be at least 1 date.")); } else { wire()->message(__("1 date was deleted.")); } } -
Is there a way to combine hooks to reduce the code
Juergen replied to Juergen's topic in API & Templates
Aaahh, I see!! This would be a solution Thanks!!! -
Is there a way to combine hooks to reduce the code
Juergen replied to Juergen's topic in API & Templates
Thanks @Zeka, but I guess in this case I have to define the functions for each "Class::method" - so I have also 2 functions ("Pages::trash", "Pages::delete") - so I can leave the 2 hooks as they are. -
Hello @ all, In my case I have some hooks with the same code which run on page "Pages::trash" and "Pages::delete" inside may ready.php. For the moment I have used separate hooks for each of them. Is there a possibility to combine them so the same code runs only once and includes "trash" and "delete"? Explanation: Instead of $wire->addHookBefore("Pages::trash", function($event) { .... run code }); and $wire->addHookBefore("Pages::delete", function($event) { .... run code }); combine them $wire->addHookBefore("Pages::trash","Pages::delete", function($event) { .... run code }); This would be more efficiently for further changes and reduces the code. Best regards
-
Hello @kongondo, I have discovered a strange behavior: I use a pagetable field inside a parent page. If click on the link inside the pagetable to open a child page inside a modal, I will be logged out from the system if the child page has a matrix field inside. I have traced down the problem and it has to do with a hook that I run on the pagetable field of the parent page (inside my ready.php): $wire->addHookBefore('InputfieldPageTable::render', function($event) { if($this->process != 'ProcessPageEdit') return; $table = $event->object; $page = $this->process->getPage(); // event table if(in_array($table->name, ['datespagetable', 'specialbusinesshourstable', 'eventspagetable', 'businessvacationpagetable'])) { if(count($page->children) == 0){ $table->notes = ""; $this->buttonHook = $this->addHookAfter("InputfieldButton::render", null, function(HookEvent $event){ $event->return = __("Here all dates will be shown afterwards if some were created."); }); } //this part of the button hook is responsible for loggin me out if I click on the link to the page inside the pagetable else { $this->addHookBefore("InputfieldButton::render", null, function(HookEvent $event){ $button = $event->object; if($button->name == 'button'){ $button->attr('value', __('Add event')); } }); } } }); Inside this hook there is another hook for rendering the "Add new" button. So this "InputfieldButton::render" hook is responsible for loggin me out (if I remove this part everthing is fine). So its not a big problem for me (I have comment it out), but maybe you have an idea, why these lines of code could lead to this behavior in combination with the matrix field. Best regards
-
Oh, sorry - my fault. I use the 2D repeater matrix from Kongondo.
-
Hello @kongondo only a question: is it possible to use a special field of a page for the field of the matrix (fe a date field, an integer field,..)?
-
Cannot install the module There is always the message that FieldtypRepeaterMatrix is not the correct version, but I have downloaded it today from the modules directory - so it must be ok.
-
Here is a new created version to track changes which works without any problems and you dont have to take care about the deletion of input values if the page was not saved successfully (like in the version before) Put this little piece of code inside your ready.php. //Compare before and after values and output a warning message $pages->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments('page'); $page->of(false); //configuration: change it to your needs $templates = ['event_businessvacations', 'event_dates', 'event_events', 'event_specialbusinesshours']; //array of templates where this hook should run $fields = ['summary', 'body']; //array of fields which should be checked //configuration end if(in_array($page->template->name, $templates)){ $changedfields = []; foreach($fields as $fieldname){ if ($page->isChanged($fieldname)) { // Page as it is in the DB $oldPage = wire('pages')->getById($page->id, array( 'cache' => false, // don't let it write to cache 'getFromCache' => false, // don't let it read from cache 'getOne' => true, // return a Page instead of a PageArray )); $changedfields[] = $oldPage->fields->$fieldname->label; } } $changedfields = implode(", ", $changedfields); if(!empty($changedfields)){ $this->warning(__("The following fields have been changed: {$changedfields}")); } } }); Change the configuration block to your needs (template names, field names). This little code snippet outputs only a warning message which fields have been changed - not more or less, but you can also run some other logics - its up to you. Note: Works also with repeaterfields, but you can only check the repeaterfields for changes in general. It is not possible to check for specific fields inside the repeater.
- 2 replies
-
- 10
-
-
-
Hello @ all, I have a required field inside a template and I want to add a value via a hook if the user enters nothing in this field. Therefore I have tried to hook before "processInput". $wire->addHookBefore("InputfieldDatetime::processInput", function($event) { $page= $this->process->getPage(); $page->of(false); if(!in_array($page->template->name, ['single-event'])) return; if($page->parent->reservationdeadline != ''){ $diff = ($page->parent->starteventdate) - ($page->parent->reservationdeadline); if(($page->starteventdate) && ($page->reservationdeadline != '')){ $page->reservationdeadline = ($page->starteventdate)-$diff; } } }); So if the user presses the save button, then it should be checked if a value was entered in date field called "reservationdeadline". If not then a value should be entered via the hook before the validation of the required field takes place. At the moment I always get the error message that there is no value entered in the required field. Could someone give me a hint how to achive this? I know I could set the option to non required and enter the value always if nothing is there but it is possible to change it before the form will be validated?
-
How to output wire message after running a hook problem
Juergen replied to Juergen's topic in API & Templates
Thanks I am always glad to read about optimizations! -
How to output wire message after running a hook problem
Juergen replied to Juergen's topic in API & Templates
Oh I understand! I only check after starting the hook if it is the right template and then make some manipulations. So it would be better to check before starting the hook if it is the right template. Thats the current case: $pages->addHookAfter('saveReady', function($event) { $page = $event->arguments(0); $page->of(false); $pages = wire('pages'); $name = $page->template->name; if(in_array($page->template->name, ['event_businessvacations', 'event_dates', 'event_events', 'event_specialbusinesshours'])){ ........ } }); But this would prevent the hook to be triggered on every page: $pageid = $input->get('id'); if(in_array(wire('pages')->get($pageid)->template->name, ['event_businessvacations', 'event_dates', 'event_events', 'event_specialbusinesshours'])){ $pages->addHookAfter('saveReady', function($event) { $page = $event->arguments(0); $page->of(false); $pages = wire('pages'); $name = $page->template->name; ........ }); } Is that what you mean? -
How to output wire message after running a hook problem
Juergen replied to Juergen's topic in API & Templates
I dont know what you mean with endless recursion. The pages will created from an array with dates (fe an array with 10 dates). So 10 child pages will be created. There is a hard limit of 732 pages that can be created (limited by the RRULE library I use to get the recurrences of dates). Ah you mean recursion functions - translation problem. By the way: latest DEV and PHP 7 -
How to output wire message after running a hook problem
Juergen replied to Juergen's topic in API & Templates
In my case they dont work if I use special characters. I have also tested it with and without special characters and nothing will be shown if I use "ü", but if I replace the "ü" with "ue" everything works as expected. I also have replaced the hard coded message text with translateable text, so there are no German Umlauts present any more. But this is really a strange thing. The main problem is that I dont get any information from the log files or from Tracy, so it was a trial and error experiment. I removed always a little part of the code to check where the problem could be. This leads me to this cause. -
How to output wire message after running a hook problem
Juergen replied to Juergen's topic in API & Templates
Yes I have done it with switch/case outside of the foreach - this was a part from the old code.