Jump to content

gebeer

Members
  • Posts

    1,386
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. @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'); }
  2. 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?
  3. @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.
  4. @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.
  5. @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.
  6. 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
  7. 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?
  8. @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
  9. @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.
  10. @Pretobrazza It might be related to the jQuery version you are using. 1.11.0 is a bit outdated. You might want to try a newer one. My map is rendering fine on 2.2.4
  11. @Pretobrazza Did you also update the leaflet-markercluster files? Because the inputfield map is not using the marker cluster plugin.
  12. @Juergen In leaflet JS there is a method invalidateSize() which checks if the size of the map container has changed and then updates the map. When you call the UIKit modal, the size of the map container changes and therefore your map needs to be updated manually. So you need to listen to the show.uk.modal event and attach a handler that updates the leaflet map. The problem here is that the map object is not easily accessible from the global document scope because the JS that renders the map is executed inside an anonymous function call. You should find a script like this just before the closing </body> tag: <script type="text/javascript"> $(function() { var mleafletmap1 = new jsMarkupLeafletMap(); mleafletmap1.setOption('zoom', 18); mleafletmap1.init('mleafletmap1', 49.572056, 10.878165, 'OpenStreetMap.Mapnik'); var default_marker_icon = L.AwesomeMarkers.icon({ icon: 'home', iconColor: 'white', prefix: 'fa', markerColor: 'darkblue' }); mleafletmap1.addMarkerIcon(default_marker_icon, 49.572056, 10.878165, '/maptest/', 'maptest', ''); }); </script> So if you try and get the map object with $(mleafletmap1), this will not return what you need. In order to have the map object available in global scope, you need to change some module code. You can find the changes at my fork in MarkupLeafletMap.module. Just copy this over your local file. Now the script before the closing </body> tag should look something like this: <script type="text/javascript"> var mymap; $(function() { var mleafletmap1 = new jsMarkupLeafletMap(); mleafletmap1.setOption('zoom', 18); mleafletmap1.init('mleafletmap1', 49.572056, 10.878165, 'OpenStreetMap.Mapnik'); var default_marker_icon = L.AwesomeMarkers.icon({ icon: 'home', iconColor: 'white', prefix: 'fa', markerColor: 'darkblue' }); mleafletmap1.addMarkerIcon(default_marker_icon, 49.572056, 10.878165, '/maptest/', 'maptest', ''); mymap = mleafletmap1; }); </script> And you can now access the map object in your script with mymap.map. Example code: <script> var myModal = $('#yourmodalID'); mymodal.on('show.uk.modal', function(){ mymap.map.invalidateSize(true); }) </script> While this is just a workaround it should help to display the map correctly. @Mats Maybe we should add something like this to the module code so in future versions a map object will be returned by default? Or do you see another way to access the map object with the module as is?
  13. @abdus As the $config variable inherits all methods and properties from WireData, you can try and use the set method $config->paths->set('assets', $config->paths->root . 'test/'); I don't have the time to try this right now. So give it a try yourself and let me know.
  14. @abdus ok, I see. When I echo $config->paths->assets in a template file I get '/DATA/htdocs/test. So it seems to be working and picking up the changed path from config.php.
  15. @abdus your code throws an error for me: `Uncaught Error: Call to undefined function ProcessWire\config()` And this code works ( note the $config instead of config() ): $config->paths->assets = $config->paths->root . 'test/'; $config->urls->assets = $config->urls->root . 'test/';
  16. @Pretobrazza I just installed latest version of this module on PW 3.0.47 I updated the getLeafletMapHeaderLines method for injecting JS and CSS then lines 168 and 173 to load @1.0.3. Then I got a JS error about the MarkerCluster. I updated all 3 files in the module's assets/leaflet-markercluster/ folder to the latest 1.0.4 versions. You can find them here: https://github.com/Leaflet/Leaflet.markercluster/tree/v1.0.4/dist After that the map is showing up fine with no errors. Pls let us know how it goes for you.
  17. @abdus In the cheatsheet there is $config->paths->assets linked to from the API docs about $config. Haven't tried it but you should be able to override it like you did with $config->paths->files.
  18. @Pretobrazza trying to answer your questions: 1. As stated in the MarkupLeaflet.module file, you are required to add the link to leaflet.js yourself. You can change the version to 1.0.3. Then you also have to change the link to the leaflet css in the same file line 106. If you decide to use the getLeafletMapHeaderLines method for injecting JS and CSS then you need to change lines 168 and 173. 2. This module does not support wms layers out of the box. You would need to expand the JS logic to use them. Over at leafletjs.com they have a tutorial on how to implement wms layers. The relevant code section in the module can be found in MarkupLeafletMap.js line 47. Following the tutorial on leaflet.js you might have to alter some other code in that file, too. 3. There is a shapefile plugin for leaflet.js that you could use to draw layers from your shape file. You can use the PW API and some PHP logic to create that shape file from the data in your pages, but I'm afraid this goes beyond the scope of this thread. This module is designed to draw markers of locations on a map where you can choose different map tile providers and assign custom fontawesome icons to your markers. All in all I think ProcessWire fits the job very well. But you might be better off just using the inputfield from this module on your pages to input the location data. And then setup the map rendering from scratch in your template file rather then using the render method that MarkupLeaflet.module provides. This should be easier than tweaking the render logic that this module provides. I can definitly encourage you trying to do this with PW and leaflet.js.
  19. Thank you for this very valuable piece of information. After implementing this in the head I still got a JS error: ReferenceError: config is not defined. I had to adjust the code like this to make it work: <script type="text/javascript"> <?php $jsConfig = $config->js(); ?> var ProcessWire = {config: <?php echo json_encode($jsConfig); ?>}; var config = ProcessWire.config; </script> No idea why my frontend form didn't pick up config from the ProcessWire object.
  20. @LostKobrakai thank you for clarifying. For me the original code did not work, even with the $event->replace = true part. That was why I was looking for a solution.
  21. This hook didn't work for me. Maybe something in the API has changed? Reading up on hooks that modify the return value, I found that only After hooks can modify it. I modified @Macrura 's code and this is working for me on 3.0.42 wire()->addHookAfter('Page::path', function($event) { $page = $event->object; if($page->template == 'landing-page') { // ensure that pages with template 'landing-page' live off the root $event->return = "/$page->name/"; } });
  22. UPDATE: I couldn't find anything suspicious in the DB dump diff. So after tinkering for a while I decided to try a workaround. I added a new role and gave it the same template-level permissions as the 'faulty' role that caused the problems. Then I assigned this new role to the admin user with the old, 'faulty' role (in addition to the old one). And this helped, the JS error is now gone. Not sure, though, what to make of this. It seems to be pointing to a problem in the settings for that 'faulty' role. But I went through the role and permission settings numerous times and couldn't find anything unusual. So for now I will let it be as it is. Although I really would like to find the real cause of the problem. Just don't know where else to look for it. Feels a bit uncomfortable to have a site running in production with a strange admin error that might reappear anytime... So if anyone reading this has an idea, please let me know. But thanks for reading anyways.
  23. @ank you may try echo $input->post['field_optionselect']->title . Or you can do a var_dump($input->post['field_optionselect']) in your template. That will tell you in which format the data is there and how you can access subfields like 'title'. For using field data on the redirect page, youcould take the values of the fields and attach them as URL query strings to the redirect URL. Dummy code // in the template with your form process the fields from your form $valueField1 = $sanitizer->text($input->post['field1']); // send them to the redirect page as url querie strings $session->redirect("yourredirecturl" . "?field1=$valueField1"); // in the template of your redirect page, you can now get the value $valueField1 = $input->get['field1']; // and then do with it what you want
  24. Hello, I'm getting a JS error in the admin backend when editing pages with template basic-page as non superuser: TypeError: a.ProcessPageList is not a function in InputfieldPageListSelect.min.js Investigating the JS, I found that the ProcessPageList function is not available on the page when I am logged in as a non superuser. The function is defined in /wire/modules/Process/ProcessPageList/ProcessPageList.min.js which is not loaded when logged in as non superuser. When logged in as a superuser, the file gets loaded. I have no fancy permission settings for that template for the role admin that the non superuser belongs to: This started happening on a site that is in development but online for some time now. I can't say which actions might have caused this. But it is a consistent error only for this one template. The site is running on 3.0.42 EDIT: The inputfield triggering the error is an image field (in fact there are 2 of them in that template) Any pointers to potential causes for this problem would be much appreciated. EDIT: The problem is not related to any file changes. When I run the same install with a DB backup, the error disappears. So it must be something that has changed in the DB. Trying to diff the DB dumps and see if I can find anything suspicious
  25. @adrian Thank you for the input. I have been able to get the query like mentioned in the post above yours. This is quite some time back now. In the meantime I've come to love Tracy Debugger. It is very easy to setup and makes debugging fun. Wouldn't want to miss it now
×
×
  • Create New...