Jump to content

modifiedcontent

Members
  • Posts

    286
  • Joined

  • Last visited

Everything posted by modifiedcontent

  1. I was trying to uninstall the FieldtypeMapMarker module, that is connected with the problematic Google Maps API that has raised their prices and produces errors. I want to replace it with Leaflet Map Marker. I uninstalled parts in the wrong order, hoping I could keep my address data. The module's uninstall is disabled, because the 'module is a Fieldtype currently in use by one or more fields'. But admin for the field in question now produces this error: Fatal Error: Uncaught Error: Call to a member function set() on null in /home/.../site/modules/FieldtypeMapMarker/FieldtypeMapMarker.module:54 Stack trace: Reuploading/reinstalling the FieldtypeMapMarker module didn't fix access to the fieldtype admin. I have tried uninstalling via the API, but don't understand how that works. I have tried putting this in a template file: $modules->uninstall("FieldtypeMapMarker"); That didn't do anything. I guess I have to put this in a function or "hook" it somewhere? I have no clue. Or would this method still perform the same check if I am allowed to uninstall? How can I nuke FieldtypeMapMarker without doing more damage? Is deleting rows in mysql really the best option? Is there a somewhat clean way to force uninstall and/or replace FieldtypeMapMarker with the Leaflet alternative?
  2. I have "solved" the issue by using window.location.origin as the ajax url. My ajax call now looks something like this: Leaving url out - using "self" as url - produces the error described above for urls based on titles starting with quotes. I wasn't able to figure out what/where/how to escape something to prevent that error. Bypassing problematic urls by using window.location.origin solves the problem. Or is there a better solution?
  3. I have this same error after updating to the latest version of PW: I haven't explored further yet, working on other things, will get to this eventually. Any news what causes this?
  4. I have Ajax search that works fine in most of my site, except on pages with single quotes/apostrophes in the title. I get this error in the log: Exception: Unknown Selector operator: '=&' -- was your selector value properly escaped? The error log gives this clue: ... wire/core/Selectors.php(460): ProcessWire\Selectors->create('title', '=&', '#039;IoT is gro...') #1 ... &#039 is a single quote. " 'IoT is gro...' " is the start of the title of the page this search is on; the URL of that page includes ".../iot-is-gro ..." But that title is not the search term. I have double-checked if I have escaped the search terms correctly and if I have used correct single and double quotes in my Ajax and search code. Again, search works fine in most of the site. How does that title end up as a "selector value" anywhere? How does the title of the page that this search is on interfere with the selector operator? I can't figure it out. Could this be a bug? I have tried/explored just about everything else.
  5. This is a self-contained basic example of how to use $config->ajax: Anyone can put this little demo in a template file and it works. Hopefully it helps other people who don't know Javascript or/and PHP well to understand how to work with Ajax in PW. Something like this is all I needed. Getting the variable(s) ($_GET) and doing something with it - in this basic example just echo it - can also be done in a separate php file in your templates folder that you can include after if($config->ajax) Here is a better example - mainly for my own reference...:
  6. Yes, of course. I don't know Javascript. I have one bit of Ajax working in my PW site, but now want to step back and try to better understand how this stuff actually works. All examples help. Thanks kongondo. Edit: Btw, I have the same problem with kongondo's latest example as with every other example of this; it only gives one part and assumes that the rest is obvious. kongondo's example is mostly generic PW PHP that has nothing to do with Ajax. The example says an 'author' var was sent by the Ajax call, but doesn't explain how - which is precisely what I am trying to wrap my head around. I am looking for an example that shows me how it all works together. Here is a self-contained basic demo:
  7. Thanks @bernhard, but this example assumes you use the default profile. I don't, so there is way too much unnecessary distracting stuff going on. I think this example only shows how you can fetch one line of text via an ajax call. Typically you'd want to send the call with parameters/variables (?) to a php script that does something with the vars and then returns something. I am looking for basic examples of that entire process. I'll keep working on my example(s) above.
  8. Like adrianmak I am struggling to wrap my head around using ajax in Processwire. I actually already have some working ajax in my sites and have worked with ajax outside of Processwire in the past, but would still like to see a complete basic example for reference/reminder how to do this in Processwire. diogo's example here is a good, stripped down start, but it is a bit frustrating to then be told we have to 'study [the javascript] part for yourself ... Google ajax, have a look at the jquery ajax methods, read a book on javascript and so on ...'. This stuff may all be completely obvious for developers who do this every day, but it is not for content developers or small business owners who have to figure this out once every few years. This works fine as a basic ajax call demo without doing anything with config=>ajax: But I think it doesn't work if ajax_info.php is in a PW folder (?) and that is why it has to go via config->ajax. I have a working ajax script in my site with this: if($config->ajax) { include 'inc/loadmore.php'; return $this->halt(); } And then the ajax call includes url parameters (?) that the loadmore.php can do someting with to send a result back. What are the ways to send variables from the javascript to an external php process script in a PW folder and then back to the page?
  9. My last image was a cropped version of the first, saved as copy. I only had two images. When I duplicated the cropped image, making it the last of three images, last() did pick it up. Variations of an image don't count for first/last etc.? I'll keep testing if this consistently happens or if I just had a cache issue or something else.
  10. Is there a way to get the last image? I thought last() worked, but it seems it doesn't.
  11. Are you sure you don't have dumb php mistakes in your templates/theme/custom functions etc.? Processwire works fine with the latest PHP versions. Start by making sure you don't have have "<? ..." where you should use "<?php ..." etc. That's what messed up my old sites a few years ago when I upgraded from PHP5 to PHP7. Even the silliest little things can give you 500 fatal errors. If there is an "<? include ..." somewhere that could lead to missing classes, the PDO error, other things that look more interesting.
  12. I sometimes get similar errors. In most sites or pages front end editing works perfectly, but sometimes it doesn't. I have no clue what causes this. The 'no changes to save' error is supposed to show up when the page is not "is_array($fields)": I have no idea what that means...
  13. Can you use something else than page ID here? Like 'name = pagename' or 'name = $somepage'. What would be the right syntax? Or could you find/get that page ID earlier in the script and put it in a variable?
  14. Thanks szabesz. I had seen some info about that and have made a "loadmore" template and set up some kind of page. But how should I configure that page? I have it hidden etc., but you still have to publish it, right? Will it behave exactly the same as a plain php inc template part? Or do I have to do other things to prevent it from being parsed and filtered etc.? What is the mysterious $config->ajax; ?
  15. Is there no way to do this without plugins? I am trying, but can't get even the most basic Ajax to work. I am trying to jQuery load() a test.php from an /inc folder in templates, but keep getting file not found. Is there something in Processwire that prevents getting template parts via Javascript? When I put 'test.php' outside of Processwire, in the root of the site, including it with jQuery load() is no problem.
  16. I'd normally use: <meta content='3; URL = https://begone.com' http-equiv='Refresh' /> What would be the Processwire way to do that with $session->redirect? Still confused...
  17. Saving a complete user object also doesn't seem to work. When I try something like this, only the username gets saved, none of the other fields - except maybe addRole: $u = new User(); $u->of(false); $u->firstname = $sanitizer->text($input->post->firstname); $u->lastname = $sanitizer->text($input->post->lastname); $u->name = $sanitizer->text($input->post->name); $u->email = $sanitizer->email($input->post->email); $u->registrationDate = time(); $u->addRole(''); $mainsite->users->save($u); Or am I doing something wrong? This works: $newuser = $mainsite->users->add(); $u = $mainsite->users->get( $newuser->id ); $u->of(false); $u->firstname = $sanitizer->text($input->post->firstname); $u->lastname = $sanitizer->text($input->post->lastname); $u->fullname = $u->firstname.' '.$u->lastname; $u->name = $sanitizer->text($input->post->username); $u->email = $sanitizer->email($input->post->email); $u->registrationDate = time(); $u->addRole(''); $mainsite->users->save( $u );
  18. Oops, kongondo. $forum should have been $mainsite. Now corrected in the example. @ Sergio, I know that, but is there a way to make that work from a "sister site" with this method? $mainsite->user->isLoggedin(); doesn't work.
  19. I kinda use this forum to keep track of how-to's and things I need. Your response will probably be useful to others looking for the same kind of thing. Tested it. Very cool. Dumping this into a template of another PW installation on the same server works: <?php $mainsite = new ProcessWire('/home/serverpath/public_html/mainsite/site/', 'https://mainsite.com/'); if($input->post->createuser) { $item = $mainsite->users->add('fred'); echo 'hello ' . $item->name; } $skyscrapers = $mainsite->pages->find('parent=skyscrapers, limit=3'); foreach($skyscrapers as $skyscraper) { echo '<h4>' . $skyscraper->title . '</h4>'; } ?> <form method=post> <input type=submit name=createuser value='add Fred to the main site'> </form> Fred gets added as a user to the main site. Pulling in content from the main site is straightforward. Is there a way to check if a user is loggedin on the main site?
  20. Thanks horst, I vaguely remembered hearing something about this, but couldn't find it. This looks perfect for my use case. I'll try this and will report back...
  21. I have one central website, with membership registration and content etc., and then several related websites with their own URL/domains, each on Processwire, all on the same server. I would like to access the database of the central website from the sister websites. How would I do that? You can't bootstrap one PW installation into another. You can include template parts from one in the other by just using the server path, but whatever you try to get/post just comes/goes to the database of the site you are on. Could you switch databases by including the config.php from another PW installation somewhere? What is the correct, secure way to do this?
  22. It would be great if 'choose file' in the image field would be able to handle other input sources than only the client's OS file manager; Amazon S3/cloud storage, Dropbox, an image folder on an intranet, another folder on the same server where PW is installed, whatever. It would be super convenient if you could just upload images to a folder/directory in the templates folder or root, without any processing, and be able to access that as a source option in the image field. Any way to make that happen? I had started a thread about this here. BitPoet posted a very helpful partial solution specifically for Zenphoto, but it would be great if there was a more source agnostic solution built into Processwire. Letting Processwire download images from any external media gallery/repository would be a good alternative to having a full centralized Media Manager. Or am I missing something that would make this impossible/a bad idea? Edit: Robin S has a module that adds one alternative input option.
  23. Thank you BitPoet, that looks like a great starting point. I'll try this and report back... This recent experimental module by Robin S - add imgs via urls - could also be part of a solution.
  24. Thanks dragan, but those threads really focus on uploading to AWS. I am looking for a way to download from an external library, instead of the client machine. I don't mind if the images are then stored/uploaded in the regular PW way. How can I modify 'choose file' in the image field to open a file manager on a URL, instead of a client machine OS file manager?
  25. OLSA, thanks for your feedback. I personally like how Processwire handles images, but I have a client who wants a central media library. That is why I want to create an external media library - Zenphoto in my case - and have Processwire "upload" the images from there instead of from a client OS file manager. How can I modify 'choose file' in the image field to use other source options? Is it possible to have that open a web-based file manager of another script on the server or on a cloud service, AWS, whatever?
×
×
  • Create New...