Jump to content

gebeer

Members
  • Posts

    1,554
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by gebeer

  1. Hello, on a fresh 3.0.62 install I have a page reference field 'mypages' with these settings for selectable pages: In my site/ready.php I have this hook: /** * custom page select */ wire()->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name != 'mypages') return; $pages = new PageArray(); $pages->add($this->pages->get(1)); $ids = $pages->explode('id'); $event->return = $event->pages->getById($ids); }); On a normal page, the hook is working and the mypages field has only 'Home' in the select dropdown . But when I put the mypages field inside a repeater, it is not working. I have this problem on a project that is in development right now and have spent quite some time to try and find the reason. Then I made a fresh PW install to verify the behavior. No matter if repeater dynamic loading is on or off, the page reference field always returns the set of pages defined by the settings in the page reference field. The hook is ignored. Can anyone please verify this and let me know so I can file a bug report. Also if you have an idea how to fix this, I would be happy.
  2. I agree with @Juergen on the start/end time input workflow with separate time input fields. Would like to use this module for a room occupancy calendar. @joshuag Is it possible with your module to have multiple events for one day with start and end times that recur daily/weekly/monthly? E.g. 17.00 - 19.00 every Monday 19.00 - 21.00 twice a month on Mondays etc.
  3. @Macrura the page edit process already loads the correct page when I call $processUser->executeEdit(); The problem is the redirection to accss/users/edit/&id=xxx that happens because of this line in ProcessPageEdit.module @Robin S fortunately PW's role/permission system got me covered here. The user is a 'member' user with own user template and parent. They have edit permissions for member users only. I restrict them from editing other member users by using a hook to ProcessPageEdit::loadPage that redirects them to their own user edit page when they try to access another user's edit page. So no security issues here. I was already thinking about making a feature request on github to support tabs in user profiles. Not too long ago I had opened a thread about this. It seems I'm not the only one who would need this. Thanks for your suggestion and code for the accordion. But I really do need tabs here. Otherwise the edit form gets too confusing for users because there are more than 20 fields. I had a look at the ProcessProfile to see if I could add the tabs functionality through a hook. But this seems not possible. Would have to extend the class and overwrite the buildForm method. Better open that feature request... But in the meantime it would be great to find a way around that redirection issue. I still don't understand why this hook in my process module public function ___executeMyprofile() { $this->addHookBefore("ProcessPageEdit::loadPage", $this, "interceptRedirect"); $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } protected function interceptRedirect(HookEvent $event) { $event->replace = true; $event->return = $this->user; } is not called at all.
  4. @benbyf thank you for your input. This is a process module called ProcessMemberDashboard that extends Process and it is for the backend. The module is built using the Hello Process Module Skeleton. I already have a working dashboard that is rendered by this module in the admin. There is a page under Admin with template admin and my ProcessMemberDashboard process assigned. Now I want to extend the module with the methods that I pasted in my first post to show the user edit screen from within my dashboard under the URL dashboard/myprofile. The problem really is the redirection that is happening. And that I can't seem to hook into the ProcessPageEdit::loadPage method from within my module. I just accidently found out that the hook is being called, when I open the URL access/users/edit/?id=5522 directly. Whereas it is not called when I open dashboard/myprofile which redirects me (through 4 redirect steps) to access/users/edit/?id=5522. So for the moment I'm still lost...
  5. @benbyf good point. It is a process module that creates a custom page in the admin. I don't know if autoload also applies to those. But I tested and added 'singular' => true, 'autoload' => true, to the module's .info.php. But same behaviour. The code in my hook method does not get executed and I still get redirected to /access/users/edit/?id=5522
  6. Hello, I have a Process module with a user dashboard and I would like to have the user page edit screen at a custom URL 'myprofile'. I cannot use the default profile edit page because it does not support tabbed interfaces. The method for executing the user edit page from within my module looks like this public function ___executeMyprofile() { $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } The user edit screen displays when I go to /dashboard/myprofile. But the request is redirected several times and I end up at the URL /access/users/edit/?id=5522 which I wanted to avoid. This happens because of this line in ProcessPageEdit.module. I guess the solution lies in hooking into the ___loadPage() method from within my Process module. But, honestly, I have no clue on how to put the pieces together. So I need some pointers on how to best achieve the goal of having the current user's edit page under a custom URL in the admin area, ideally in the scenario of a custom Process module. Any help would be much appreciated. EDIT: I tried some variations of hooking like public function ___executeMyprofile() { $this->addHookBefore("ProcessPageEdit::loadPage", $this, "interceptRedirect"); $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } protected function interceptRedirect(HookEvent $event) { $event->replace = true; $event->return = $this->user; } but the hook is not being executed at all. Also when placing the call to the hook in my Process module's init() method. Also when using an After hook and not replacing the hooked method. No luck so far...
  7. One more thing comes to mind: we aere always talking file permissions. Did you also check folder ownership/permissions?
  8. 3) when checking for file_exists, always use full path. Does it return false? If not, the file is readable. In the docs it says This function returns FALSE for files inaccessible due to safe mode restrictions. However these files still can be included if they are located in safe_mode_include_dir. So you might want to check for safe_mode. But you are saying other sites on the same server are running fine. So I guess its not safe_mode related 1+2) Did you compare file ownership and permissions with other sites installed on the server, anything unusual? Maybe have a look here to understand how permissions on host europe servers work: https://www.hosteurope.de/faq/webhosting/webpack/dateirechtestruktur/ Other than that I would have no clue either...
  9. @Robin S spot on! Thank you very much. This is working. Except for I had to exit the hook for template repeater_repeater. Otherwise I got an error "Call to a member function not() on null" for the "->repeater->not('published=0')" part of your code. The working version now reads wire()->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments[0]; if($page->template == 'repeater_repeater') return; if($page->isChanged('repeater')) { $old_repeater_value = $this->pages->getById($page->id, array( 'cache' => false, 'getFromCache' => false, 'getOne' => true, ))->repeater->not('published=0'); // exclude as-yet-unpublished items bd($page->repeater->count, 'new count'); bd($old_repeater_value->count, 'old count'); } });
  10. Did you also check the owner:group for the images that are not loaded, e.g. /site/templates/img/square/kinderlieder-ueber-den-fruehling.jpg? I had an issue once with host europe where the owner:group of files were wrong after uploading through FTP. I needed to ask their support to change file ownership to default. In the logs it says: No such file or directory for the images that are problematic. Are you sure that they are there? And in your templates/php/site/SquareImage.php you could do a check like file_exists() before processing the images to avoid a crash in case the image is not there.
  11. Hello, To compare repeater items when someone added or removed items to/from the repeater, I use this hook wire()->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments[0]; if($page->isChanged('repeater')) { //get page before changes : https://processwire.com/talk/topic/9734-determine-old-vs-new-value-of-field-when-saving/?do=findComment&comment=106166 $oldPage = $this->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 )); bardump("new count: {$page->repeater->count}"); bardump("old count: {$oldPage->repeater->count}"); } }); When I add a repeater item, both counts are identical. But they shouldn't. When I remove a repeater item, the counts come out correct. I verified this behavior on a blank PW 3.0.62 install. So I think it is a bug. Can someone please check if they find the same behavior? Thank you. I also tried it with this hook wire()->addHookAfter('Page(template=basic-page)::changed(repeater)', function($event) { // old value bardump($event->arguments[1]->count); // new value bardump($event->arguments[2]->count); }); Same outcome. For the second hook to fire, you need to adjust line 1005 in wire/core/Wire.php to read if(($hooks && $hooks->isHooked('changed()')) || !$hooks) { because of this bug.
  12. @Robin S thank you for looking into this. I can confirm that after making the change to Wir.php the hook fires. I will open an issue. EDIT: added issue on github
  13. A quick google search brings up a relatively recent module Facebook Events. Reading through the docs and code should get you started.
  14. @SteveB Have you been able to solve this? I also needed a hook to intercept ProcessPageAdd. Following Pete's concept, I hook into ProcessPageAdd::execute. This works fine. The hook is placed in admin.php.
  15. Hello, I read about conditional hooks and wanted to utilize them. In the process of trying to implement them I found that they do not get called. So I reduced my hook to a minimum wire()->addHookAfter('Page::changed', function($event) { die('changed'); }); And nothing happens at all. Also with Page::changed(title) or Page(template=basic-page)::changed(title) no luck. In the code comment in Wire.php it says: "Hookable method that is called whenever a property has changed while change tracking is enabled" I see that change tracking is enabled as wire()->addHookAfter('Pages::saveReady', function($event) { if($event->arguments[0]->isChanged('title')) die('changed'); }); is working. The hookable method ___changed() in Wire.php is empty. I tried this on 2 different installs PW 3.0.61 and 3.0.62 Can anyone please confirm or let me know if I'm doing anything wrong here. Thank you.
  16. @kixe thank you for clarifying. I had already suspected the repeater to be the cause.
  17. @Robin S thank you again for checking. I reproduced this on a pretty virgin 3.0.62 install. The only hook I have there is the one from my first post which only dumps 'added', nothing else. Only thing I had added to the blank PW install was a repeater field. When I remove the repeater field from the template that I use to add a new page, then Pages::added gets only called once. With the repeater field in the template it gets called twice. When a new page is created that has a repeater field, then also a new repeater field page is created. "Session: Created Repeater Page Parent: /logon/repeaters/for-field-157/for-page-2244/" Hence the 2 calls to Pages::added. But this still does not explain, why 2 pages get created when I hook into ProcessPageAdd::execute. Here's my code: wire()->addHookBefore('ProcessPageAdd::execute', function($event) { bardump('memberadd'); $user = wire('user'); if($user->hasRole('superuser')) return; // This is workaround so that only one page gets created on member add if($this->session->get('newMember')) { $this->session->redirect("../edit/?id=" . $this->session->get('newMember')['id']); } // end workaround if ($this->input->get->parent_id == 29) { // 29 = users parent page $parent = $this->pages->get(1019); // members parent page $uid = $this->sanitizer->pageName(uniqid()); $newUser = new User(); $newUser->parent = $parent; // members page $newUser->template = 'member'; $newUser->name = $uid; $newUser->addRole('member'); $newUser->set('admin_theme', 211); $newUser->save(); $newUser->name = "uhti{$newUser->id}"; $newUser->save(); $this->session('newMember', ['id' => $newUser->id, 'creatorId' => $user->id]); // used to confirm new member $this->session->redirect("../edit/?id={$newUser->id}"); } }); This one gets only called once, but 2 member users are created, if I comment out the workaround. I have no page creation functionality in the Pages::added hook: public function memberAddedHook($event) { $user = $this->user; $userPage = $event->arguments[0]; if(!$userPage->getChanges('firstname')) return; bardump('addedHook'); }
  18. Hello, I noticed that the Pages::added hook gets called twice. PW 3.0.62. To test , add this to admin.php wire()->addHookAfter('Pages::added', function($event) { bardump('added'); // needs Tracy Debugger }); Can anyone confirm this? It gives me trouble when adding a hook that skips the page add step (for users), following Pete's concept. There will always be created 2 new pages which I need to avoid. Is it a feature or a bug?
  19. @loukote I just checked on a 3.0.61 install with leaflet 2.8.1 and 3.0.2 and here it is working as expected, even if not logged in to the backend at the same time. This could be a permission related issue. Do you have any access restriction set on the template that renders the map? You can check the value of $page->inlineScript on the page that you output the map after the code that renders the map. If it has a value, then the script code should be prepended to the closing </body> tag.
  20. @Robin S thanks for checking. I have quite a few other hooks going on that might interfere. I thought I had checked on them already. But will do another thorough check and get back here.
  21. @Robin S That is pretty neat! And I will use it to execute my logic. For testing, I am using this now: $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments[0]; if($page->template == 'repeater_history') bardump($page->isChanged()); // this line is not executed when adding an image and then saving the page }); BUT it still doesn't trigger page change when I upload an image to the repeater item and then save the page. Deleting the image does trigger page as changed. So same behavior as with my above hook code. Looks like a bug to me. On a normal page (non repeater) the change event is triggered when uploading an image and then saving the page. Only for repeater pages this does not happen.
  22. Hello, I have a repeater field with an image (single) field. I would like to attach a hook when the repeater item has changed. But the change event is not triggered, when uploading an image. When removing an image the repeater item shows as changed. Here's my hook $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments[0]; if($page->template != 'member') return; $historyItems = $page->get('history'); // repeater field foreach ($historyItems as $key => $item) { if($item->isChanged()) bardump('CHANGED'); } }); This looks like a bug to me. Can anybody reproduce this? PW 3.0.61
  23. Hello, I have a custom member user template with quite a lot of fields and would like to organize the fields of the profile edit page in tabs. I created tabs and they work just fine in the page edit screen. I enabled all the tab fields for the profile edit page in the ProcessProfile module Admin > Modules > User Profile. But on the profile edit page they do not appear as tabs. I found that wire/modules/Jquery/JqueryWireTabs/JqueryWireTabs.js and JqueryWireTabs.css do not get loaded on the profile edit screen. EDIT: even if I manually load in JqueryWireTabs.js and JqueryWireTabs.css, the tabs are not displayed. Is this intended behaviour or a bug?
  24. @tom0360 If you want more control over bootstrap and compile it yourself with SASS, I made a site profile which also includes some functions for rendering drop down menu and accordion: https://github.com/gebeer/site-pwbs
  25. @Pretobrazza with the options markerLinkField and markerTitleField you can pass field names. The content of those fields on your page will be used as title and url within the marker popup. To apply the options you have to pass them to the render method <?php $options = array('markerIcon' => 'flag', 'markerColour' => 'purple', 'markerTitleField' => 'title',); echo $map->render($page, 'map', $options); ?> If you want to have additional popup content you can use the option 'popupFormatter' which is documented in the Readme.md. You can pull any content from any page and put it in the 'popupFormatter' option's callback function.
×
×
  • Create New...