gebeer

Members
  • Content count

    701
  • Joined

  • Last visited

  • Days Won

    6

gebeer last won the day on January 2

gebeer had the most liked content!

Community Reputation

601 Excellent

About gebeer

Profile Information

  • Gender
    Male
  • Location
    Germany/Thailand

Recent Profile Visitors

6,787 profile views
  1. @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
  2. 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...
  3. One more thing comes to mind: we aere always talking file permissions. Did you also check folder ownership/permissions?
  4. 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...
  5. @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'); } });
  6. 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.
  7. 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.
  8. @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
  9. A quick google search brings up a relatively recent module Facebook Events. Reading through the docs and code should get you started.
  10. @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.
  11. 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.
  12. @kixe thank you for clarifying. I had already suspected the repeater to be the cause.
  13. @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'); }
  14. 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?
  15. @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.