Jump to content

modifiedcontent

Members
  • Posts

    279
  • Joined

  • Last visited

Everything posted by modifiedcontent

  1. 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?
  2. 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.
  3. Is there a way to get the last image? I thought last() worked, but it seems it doesn't.
  4. 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.
  5. 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...
  6. 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?
  7. 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; ?
  8. 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.
  9. 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...
  10. 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 );
  11. 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.
  12. 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?
  13. 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...
  14. 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?
  15. 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.
  16. 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.
  17. 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?
  18. 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?
  19. Is there a way to change the input options for the images field? I am trying to figure out if it would make sense to use an external script like Zenphoto as a central media library/manager. How could I connect that with Processwire? 'Choose File' in the images field would have to be able to open that 3rd party media library or a directory on the server or some cloud service instead of (only) the client file manager. Could justb3a's field type module Image Extra be part of the solution? I will try that and report back. Other field types/modules? I know there is a pro module Media Manager that does look very slick, but would prefer to make this work with a mature, tested 3rd party script if a central media gallery is never going to be a core Processwire feature.
  20. Either or both! A JSON field would probably be most useful. I am watching some of those other threads. Simplepie takes input as a list of comma-separated links, not key => value - does that type of array have a name? I managed to make it work with a repeater field.
  21. Another dumb question: Is there a field type for a text-based array? In my case I need to store an array of RSS feeds for SimplePie. Storing that list of links in a textarea - text formatted to look like an array - doesn't work with the script. It works with one link. The images field is an array. I assumed there would be an equivalent for URLs or text in general. Or is there another approach for these cases? Edit: I guess using the optional (module) Repeater field type is the best solution in this case? I have now a working solution based on that. Still curious about other ideas.
  22. Seriously, you don't want to know. Awful mess. I disagree with my client, but have to try to meet him halfway. See edit in my comment above for more details. Again, I am not asking for a solution for my particular issue. This discussion is probably closer to what I am looking for.
  23. Is this all still valid? Setting permission in the ProcessModule for the custom admin seems to be the cleanest way to make that admin available to a specific role. But yes, how do you then hide the main page tree for that role? My custom admin will be an alternative to the main page tree edit interface. Is AdminRestrictPageTree still the (only) way to achieve that? That module is still alpha, getting kinda old, not explicitly compatible with 3.0 Here is another thread about the same issue; how to hide the tree when there is a custom admin for a specific role. That thread fizzled out in 2015. If you want to create an admin that looks completely different from the standard admin, is it a better approach to use a custom myadmin template?
  24. Yes, of course it is. Unfortunately I actually have a client who thinks Processwire's admin area is confusing and wants an admin area that looks exactly like the horrible system he is trying to replace. I have to restructure/reorder all the standard admin functionality/edit screens into something he recognizes to gradually lure him over to the PW dark side. But apart from that, I am looking for the most basic proof of concept. Basic stuff that the default admin already does, stuff that everybody understands; how would you replicate that in a custom admin area? I am looking for a guide for the basic principles. Most modules seem to come in a folder/dir with other file types like js and css, not a single text file. How that works is basic module writing of course, but I was hoping to see some pointers in your tutorial how to structure that for a custom admin area. Your hello-page2 example still goes in the same single text file? Edit: Let's say you want to create a wizard style interface for adding/editing content, that starts with a title + body + images form, followed by steps or dropdowns to put the content in the right page. Instead of the page tree. More content-centric instead of structure-centric. I prefer the Processwire approach, but my client is used to that content-centric approach. But it doesn't matter what exactly I am trying to achieve in this case. I am looking for a general basic recipe how to create an alternative custom admin area or how to completely restructure the admin. Bernhard's tutorial is more about adding advanced features to the existing admin.
  25. bernhard, I appreciate the effort and enthusiasm that has gone into this tutorial, but for me it goes too deep into the weeds too quick after the basic 'hello world' example. If I want to add a custom admin page to post/edit basic content - title, body, image - how would I do that? Would I add the code for that form to the ProcessSimple.module file or somewhere else? The stuff about panels, tables and charts is very confusing to me. If I want to create a custom admin with several pages/functions, would I need several *.module files for each or would there be a *.module folder/directory where I can add different files/processes? Can I start my custom admin area simple and build it out later, add stuff to it? Or should I build it all at once as one module? I am trying to figure this out on a "concierge job", so my brain/concentration operates at below 50%.
×
×
  • Create New...