-
Posts
1,424 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Juergen
-
How to hook after saving a page inside the setup section
Juergen replied to Juergen's topic in General Support
Sorry, there was a mistake!!!!!! It affects pages which are under the Setup section!! -
How to hook after saving a page inside the setup section
Juergen replied to Juergen's topic in General Support
The problem is that the hook will not be triggered after pressing the save button. This doesnt work too $pages->addHookAfter('saveReady', function($event) { $this->message('Save button pressed on an admin page'); }); If I press the save button of a page outside of the admin page it works. It affects only pages under the admin page. -
Hello, I am struggeling with a problem to run a hook after the save button of a specific setup page was pressed. I thought that I can use a default "saveReady" hook inside the ready.php to run a specific logic, but it doesnt work. I use the id of the admin page to run this hook only if the save button on this page was pressed. This is the test hook that i run inside ready.php on an admin page with the id 39407 $pages->addHookAfter('saveReady', function($event) { $page = $event->arguments(0); if($page->id == 39407){ $this->message('Save button pressed on an admin page'); } }); If the hook was triggered the message should appear after saving, but nothing will be displayed. So it seems the hook will not be triggered. Tracy didnt display the hook too. What is the correct way of triggering hooks on admin pages? I hope someone can help me out.
-
[SOLVED] Best way to search a site including hidden child pages
Juergen replied to Juergen's topic in General Support
Thanks to all for their contributions! Finally I ended up with the solution from @Robin S and a hook in the ready.php. In my case I only need to search the title and body fields in the hidden children. The reference field is located in the parent template. Instead of adding the pages manually to the reference field i use a hook to add a child page after save to the reference field. The reason behind this is if there will be added a new child page, by default you have to add the new page manually to the page reference field. This makes it a little bit complicated. So I decided to add the following hook inside the ready.php to add the newly created page automatically after save to the page reference field. $pages->addHookAfter('saveReady', function($event) { $page = $event->arguments(0); $page->of(false); if($page->template->name == 'privacy-policy-item'){ $page->parent->of(false); if($page->parent->hasField('privacyref')) { $page->parent->privacyref->add($page->id); $page->parent->save('privacyref'); $this->message('Page reference was added to parent template'); } } }); The child template in my case is called "privacy-policy-item". The page reference field in the parent template is called "privacyref". So if a new child page was created and the save button was clicked the new page will be added automatically to the reference field. Therefore the new page is fully searchable without doing something manually. Best regards -
It would be nice if a description field will also be added to the templates. At the moment only a label field is included. In my case I use a custom dashboard on the frontend with links to the different content types. On the frontend the description field could be used as a title attribute for the links. So the editor could see if it is the right content type he is looking for by hovering over the links. On the backend side the description could be displayed under the title of the template. This could be a useful addition to give users a little more information about the template itself. Example for a description: Template for creating an event with start and endpoint and the possibility to enter prices, locations, number of participants and more.
-
- 3
-
-
[SOLVED] Best way to search a site including hidden child pages
Juergen replied to Juergen's topic in General Support
Wow, thanks a lot!!!! -
[SOLVED] Best way to search a site including hidden child pages
Juergen replied to Juergen's topic in General Support
This was not clearly written by me. Sorry! I have used "include=hidden" and the page will be found, but the URL did not point to the parent. Thats the way to go! -
[SOLVED] Best way to search a site including hidden child pages
Juergen replied to Juergen's topic in General Support
Thanks @horst, I have also thought about this to add the values via a page save hook to a field, but I have hoped that there will be a more elegant solution (fe. via a page reference field or something like that). Storing the same data twice is a little bit of overhead. -
Hello , I want to know how others deal with site search and hidden child pages. Some of my pages have children which status is set to hidden. The parent page is the main page and the only visible page. The child pages provide some content wich will be displayed on the parent (main) page. fe my main page is a page about privacy policies of several social networks - Privacy policy (main page, visible) -- Privacy policy for Facebook (child page, status hidden) -- Privacy policy for Twitter (child page, status hidden) -- Privacy policy for Linkedin (child page, status hidden) So on my main page all the texts of the child pages will be visible. Problem: If I use my search form on the frontend and search for a word (term) that is included in a hidden child page, it will not be found, but this word (term) is visible on the main page. I want to achive that the word (term) will be found, but the URL should point to the main page (in this case the privacy policy page). I guess that others are struggeling with this problem too. How do you deal with this problem? What would be a good approach? Thanks in advance
-
I also have a lot of these requests in my 404 logger protocol . I think if there is module that can handle it - use it. Check if the module is installed first. If not output a message that this feature is only available if Jumplinks is installed. I dont have Jumplinks installed and I dont know how well it works, but before starting to code from the beginning I would try to use an existing solution first.
- 35 replies
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
Thanks for the hint @PWaddict, I have updated the code on the first post !
-
Just a thought: I think it would be nice to store the banned IPs also in a logfile, so you have them in one place with the other protocols. Fe: $log->save('blackhole', 'Banned IP') You can also add fe a checkbox in the module settings to offer enabling and disabling of this feature. What do you think? Might this be useful for others too?
- 35 replies
-
- 2
-
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
Is it possible to use HTML tags in log files and how?
Juergen replied to Juergen's topic in General Support
Its a fast and simply way to store sent mails. Its only there for the purpose if someone says he has sent a mail, but the site owner doesnt receive it. The log file will be written after PHP mailers send function was successfully triggered. -
Is it possible to use HTML tags in log files and how?
Juergen replied to Juergen's topic in General Support
Thanks for testing @kongondo, but I have tried this before with no luck. Another opportunity would be to add separate colums (<td>) for each entry, but I also dont know how. Serializing the entries dont work. -
Hello @ all, I am logging all submissions via my contact form in the log files with the following line of code: $log->save('contact-form', 'Email: '.$emailvalue.'<br />Betreff: '.$subjectvalue.'<br /> Nachricht: '.$commentsvalue); So the logfile is called "contact-form". Unfortnunately all br-tags will be displayed as letters and not as line-breaks. Maybe someone can give me a hint how to use line-breaks in log files. Thanks
-
Its not so important, because only bad bots will see it and probably no humans (I hope so). By the way 2 bots from China were caught in the trap - works!!!
- 35 replies
-
- 2
-
-
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
Works like a charm now! Would be great if the hard coded url of the "contact the administrator" page could be selected out of PW pages. Thanks for the update!!! Edit: It would be better if you add multilanguage support to the custom message textareas
- 35 replies
-
- 1
-
-
- antispiders
- anticrawler
-
(and 2 more)
Tagged with:
-
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.")); } }