Jump to content

gebeer

Members
  • Posts

    1,394
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. @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.
  2. 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.
  3. @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.
  4. 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/"; } });
  5. 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.
  6. @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
  7. 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
  8. @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
  9. For hosting environments where you cannot change my.cnf and make settings persistent, you can do this: https://github.com/processwire/processwire-issues/issues/28#issuecomment-252870084 I just implemented it and it is working fine.
  10. Spot on, thank you. In my case it was ONLY_FULL_GROUP_BY that caused the problem This helped solving it:
  11. @LostKobrakai That did the trick. Site is back to normal now. Thanks a lot!
  12. @rastographics Which operating system are you on and which docker version are you using?
  13. @felic Yes, it is possible on the console and through phpadmin. But the changes can only be made by a user with root privileges and they will not persist. So after a restart of mysql they will be lost. In most shared hosting environments we are not allowed to do these changes ourselves...
  14. @Robin S Thanks for the tip. In 3.x there is a setting $config->dbSqlModes = array( "5.7.0" => "remove:STRICT_TRANS_TABLES,ONLY_FULL_GROUP_BY" ); in https://github.com/processwire/processwire/blob/master/wire/config.php#L869 But it seems that 2.8 is not supporting those mode settings. At least I cant find anything related in https://github.com/processwire/processwire-legacy/blob/master/wire/core/WireDatabasePDO.php or https://github.com/processwire/processwire-legacy/blob/master/wire/config.php
  15. @justb3a Did you change the settings in the my.cnf file or through phpmyadmin? I read that in order to make the changes persist across DB server restarts, we have to change my.cnf. What for shared hosting where we only have access through phpmyadmin?
  16. @adrianmak We're ecperiencing problems on a PW 2.7.0 install after MySQL upgrade to 5.7. Do you have any further findings, are PW 2.7 and MySQL 5.7 versions not compatible or did you get it to work?
  17. Hello, on a page that is live for over a year now, we get this error when trying to add a new child page to a certain parent: "Field 'sort' doesn't have a default value" EDIT: here's the whole error message: Couldn't find anything related on Google so I post here. The parent page has set sort for children by created date. No errors in eeror or exception log. When trying to save the new child page, the system also says that the name is already taken. But page under same parent with same name does not exist. Page is created in the background, though. When manually changing the name of the page (adding "-1" to the name), a new page is saved in the background but the system still says that the name is already taken. Now I'm clueless of what to do. Any help would be much appreciated.
  18. @rastographics you're welcome. I didn't know much about docker either, before I put this together. Took me 2 days to get to know basic concepts and find existing images that I could base mine on. Read about docker-compose, too. But I decided to first learn proper use of docker with native docker utilities before using some wrapper around it. Makes me feel more confident when it comes to solving issues. Also, when you have setup your containers once with docker run ..., they are very easy to handle. Example: you have set up 3 containers following the README.md with names nginx, mariadb, example_com To stop them, just run: docker stop nginx mariadb example_com Next time you want to work on example_com: docker start nginx mariadb example_com Then you setup a fourth container with a new dev project with docker run --name example2_com ... To work on that project. you do: docker start nginx mariadb example2_com Its that easy. So I have no need for docker-compose. Just had a very quick look at wocker and it looks interesting. With my system I can start up a new project within less than 5 minutes. And thats quick enough for me
  19. @microcipcip WireHttp is meant as a replacement for external PHP http client libraries like guzzle etc. You would want to use these when you 'talk' to the REST API that you set up with PW. Don't confuse this with clsource's Rest Helper class that I am using in my tutorial. You would still use that to build your REST API on the PW side. Today, If I wanted to develop a PW application that exposes JSON data through an API I would go with the brandnew GraphQL module by Nurguly. Seems like a much cleaner approach compared to REST.
  20. As for organising your forms in the page tree, you could also save all form pages under one parent. When you save a form page via API, you can set the user who has created the form (which is the logged in $user). Some dummy code to achieve this $form = new Page; $form->template = 'form'; $form->parent = $pages->get('template=formparent'); /* set user who created this form */ $form->set("createdUser", $user); Then in the user's dashboard you get all the forms for that user with something like $forms = $pages->find("template=form, created_users_id={$user->id}"); I'm using this approach in some projects with frontend user dashboards and it works really well. Users can only see the content they created. All user content (here forms) lives under one parent page which makes it easy to create and query. Important note: in the backend you need to edit the form template and enable "Allow the 'created user' to be changed on pages?" under the "Advanced" tab. For the admin dashboard where forms for all users should be listed, you might want to spend a few bucks on Lister Pro. This saves you from developing a custom admin page. Lister Pro is very powerful and you can create a Lister that shows all pages with template form. You can list all forms sorted by created date, filter for forms of specific users etc. Also inline editing for the status field is possible. So admins can change the status very quickly. For the multi-step form: I also think that using Angular here would be overkill. I have a multi-step form that I render with PHP and use some very simple JS to step through the form. The form is divided into fieldgroups that reflect the steps. In the JS you can use AJAX to save the steps of the form that have been completed. Since you want to store the form data as JSON, you might want to look into a JS form framework that renders forms from JSON, something like Alpaca Forms. This would save you from creating the form rendering logic on the PHP side. They also support multi step form wizards. And, finally, what @adrian suggested above for creating users under different parents makes a lot of sense. I use this approach quite often.
  21. @microcipcip At the time of writing this tutorial and coding a real world application that uses this approach, I wasn't aware of the fact that PW brings it's own http client Class WireHttp. So today I wouldn't bother using an external library like guzzle or phphttpclient. I would go with WireHttp. It has all the methods you need. @clsource thanks for answering microcipcip's questions so thoroughly.
  22. Update: Working with this setup I found that installing modules with the installer from the admin did not work because php-zip module was not installed. I fixed this and pushed the new image and Dockerfile to dockerhub and github.
  23. @kreativmonkey you can leave out the namespace if the site works. You would need them if you were using other PHP libraries inside ProcessWire that might have naming conflicts. Otherwise you don't need them to make PW work. But in general it is a good practice to use namespaces if you are know what the implications are.
  24. @arjen I updated the README at https://github.com/gebeer/alpine-php-processwire Hopefully this makes things more clear. And here is a great resource for some basic docker commands (listing/removing of images, containers and volumes). I needed them a lot when experimenting... Please let me know how it is going for you.
  25. @kreativmonkey The thing is when you upgrade to 3.x and declare the namespace only in one file, it will most likely not work. You'd have to put the namespace line on top of all of your template files. Since the namespace is not declared in home.php but in function.php the file compiler in PW 3.x runs into errors. So either declare the namespace in all template files or in none. @all Please correct me if my assumption is wrong. At least this is how I understand it. When upgrading to 3.x it is a good idea to read up on PHP namespaces and search the forum for related threads. The error message in your first post points towards a syntax problem. But I can't spot an error in your syntax. Maybe someone else?
×
×
  • Create New...