Jump to content

modifiedcontent

Members
  • Posts

    279
  • Joined

  • Last visited

Everything posted by modifiedcontent

  1. Returning to this after 5 years, one of my annual Christmas/New Year web development projects. I think I got something working 5 years ago, but it was clunky and too confusing to implement throughout my sites. What is the recommended approach for 2023? Wish list: Infinite scroll - within reason, turning into a 'More' button after the first dozen items Lazy loading Not using plugins/modules ... Should I start with pagination? Or some other built-in feature to creates an array of items on page load, ready to be added to the page as you scroll down? The clunky first attempt called items by batch based on the latest added item, I think. I'll add my solutions here as I find them, using this thread to keep track of what I'm doing. Any tips/suggestions appreciated.
  2. Thanks for the response @wbmnfktr. I've had this Leaflet module in my sites for years, but it has some problems. I was just wondering if there were better alternatives for 2023. Didn't Google Maps go fully commercial at some point, with unworkable limitations? What inputfield would that be? I think I use an inputfield StreetAddress that doesn't integrate with LeafletMapMarker at all. LeafletMapMarker has its own Address, Latitude, Longitude, Zoom fields, and then it also has a search field on the map. Entering an Address never works; the module forces you to use the search field on the map and that only finds a few weird irrelevant "landmarks" and in module's Address field weird addresses are added, sometimes adding words in Russian characters. Manually adding lat/long is usually the only way to get the marker in the right location. I have to use some other tool to find the correct lat/long. Is there a way to get better integration? Just add a street address somewhere, generate a correct lat/long, not have the MapMarker module make up all kinds of stuff. Also sometimes the map does not "kick in" in the front end; I just get an empty space. Probably some javascript not loading or loading too late. And probably just my template mess, but I haven't been able to troubleshoot/fix it yet.
  3. This module hasn't been updated since 2018? What is currently the best way to put a map in a Processwire site?
  4. I am using this module and am generally happy with it. Would be good if someone would maintain it. One issue I have; maps sometimes don't show up. I guess the javascript doesn't kick in somewhere and then you get a empty blank block. What can I do to make sure the javascript kicks in? Or something has to happen in the right order? Has anyone else seen this issue and fixed it? Probably not even 100% related to the module; it may just be something dumb in my templates.
  5. Just started using the image focus feature - very cool, works great, fundamental workflow improvement. 🙂 What happened to the optional, future zoom feature that Ryan showed in the video here? Can I enable it somewhere? Is it still coming? Or left out to keep things clean and simple? Other ways to achieve the same?
  6. Upgrading the secondary site to the same version as the "mothersite" fixed the issue. As explained here: 'Ideally all instances should be running the same exact version of ProcessWire if possible. At minimum, the versions must be close.'
  7. Upgrading the secondary site to the same version as the "mothersite" fixed the issue. As explained here: 'Ideally all instances should be running the same exact version of ProcessWire if possible. At minimum, the versions must be close.'
  8. Several of my sites stopped working. Has this multi-instance support been removed somewhere between v3.0.162 dev and 3.0.198 dev? Is there now another way to achieve the same? I urgently need to restore my sites. ? Is it related to this? Setting $config->useFunctionsAPI to 'false' makes no difference, so I guess not. The mothersite on the older PW version is still accessible with useFunctionsAPI on false or true; trying to access content from sites on newer PW versions produces a nasty 503 Service Unavailable error.
  9. I am now starting to rebuild this from scratch. I have a main "mothership" site and want to display content from that site in a secondary site on the same server, with another URL. I had three sites working like this with a solution that involved $config->useFunctionsAPI that worked fine, until an upgrade somewhere between 3.0.169 and 3.0.198 dev. Did anything change recently? Where are the current instructions for this? I see a lot of stuff about multisite, but that seems to be about managing multiple sites with different databases from the same admin etc. When I put this in my home.php template: <?php $forum = new ProcessWire('/home/bizpartn/public_html/mymothershipsite/site/', 'https://mymothershipsite.com/'); echo $forum; ?> I get this error in the browser: No error message in logs. If I uses another site on a lower PW version, echo $forum outputs this in the browser: I guess this was "multi-instance support", I originally worked on it here. Has it been deprecated/removed?
  10. My multiple instances (?) broke in upgrade somewhere between v3.0.169 and 3.0.198 dev. Did something change? What is currently the way to use this? I have to go back to basics and try to rebuild it.
  11. I have three secondary websites that get content from a related mothership website's database via the API - "multisites" or multiple instances with $config->useFunctionsAPI enabled and `new ProcessWire()` etc. This broke for mothership websites that were upgraded to PW version 3.0.198 dev; it still works fine for the one that is still on 3.0.169. If I edit the other secondary sites to get content from the v3.0.169 site, they work fine as well - but with the wrong content obviously... With the v3.0.198 dev mothership sites, I now get error page 503 on the secondary websites that should get content via the API. The log says: 'Error: Exception: Unrecognized operator: % (in /path_to_my_pw/wire/core/Selectors.php line 410)' - I can't find info where that problem starts. There is probably bad coding/syntax somewhere in my template files, but I can't pinpoint it. Any suggestions? What changed between 3.0.169 and 3.0.198 dev? What could cause 'Unrecognized operator: %'? The selector error could be related to this?
  12. @da², there are probably several standard ready-to-use scripts floating around on this forum and elsewhere and I think there was another module - curious to hear responses from others, I haven't checked recently. Here is a login/register process from the main PW developer Ryan Cramer. It's 5 years old, but I think it should still work and that it was provided as an example that you can adapt and expand to suit your needs. And if you really need a generic out of the box solution, you could always use the Pro module. Here are some of the old threads where I was trying to solve some parts of this, like best practices to secure registration and front-end password reset. Also see this post.
  13. @da² I developed my own login/register process with a lot of help from this forum, I think just before that LoginRegister module(s) appeared. There are a lot of advantages creating your own process and PW makes it relatively easy. Once you have it, you can reuse it for different sites. Probably not super helpful in your case, but I imagine this is how many PW users approach it. Curious to see other responses...
  14. I am trying to put together a front end form for a repeater field. The solution in the previous post gives helpful clues, but my repeater field doesn't need new pages and templates I think - isn't that a Page Reference field? My repeater field is for RSS feeds; name 'feeds', type 'Repeater'. The field used by 'feeds' is name 'rssfeed', type 'URL'. To store a regular field I'd use something like this: But instead of one value it would be adding one or more values to an array, somehow done with the fieldname[] and for ( $i=0;$i<$fields;++$i ) stuff, but without new Page() and template etc.? Not sure how to put that together, will try things this weekend... Is there a code example somewhere? Is there a way to get the same fancy repeater input field as in the admin area?
  15. Thank you @horst! That was the problem. I was using $sanitizer->text() on the field. If I remove that it works fine. There is a $sanitizer->textarea() and $sanitizer->purify() is probably best for my use case.
  16. Input from a textarea field via the front-end gets truncated; only the 246 characters (with spaces) get saved, nothing longer. When I enter text for the same body field via the admin back-end there is no limit and it also shows up fine on the front-end, but when I edit and save that same longer text from my front-end form, it gets cut at the same spot around 246 chars. I have tried with and without Ckeditor, but that makes no difference. I guess I can eliminate Ckeditor as a possible cause. What else could it be? This may be related or not. Any other ideas appreciated.
  17. Why would I do that? I now have the delete button figured out - with your help! - so why would I start over again? I do normally avoid modules and try to use built-in methods that I understand. Agreed with your point. But for the comments section, this is a module by our fearless leader @ryanand as far as I understand it, I like his approach; looks like a solid future-proof basis to move forward with. So I need to sort out an edit button next, probably next Christmas... If anyone has any ideas, please post in this thread. I guess for an 'edit' button you would use updateComment()? Edit field via ajax?
  18. Comment delete button The delete button itself; only shows up for the logged-in author of the comment: jQuery to handle a click on the delete button via ajax: PHP to process the ajax request and delete the comment: This seems to work. Let me know if you see mistakes or ways to do this better. Next I need a comment edit button...
  19. Hello @Jan Romero, thank you so much. This gives me a lot of new stuff to work with and try tomorrow morning. ? Happy New Year! Edit: I kept getting similar errors with your suggestions, but after trying a lot of variations with your input, this seems to work: $field = $page->getField('comments'); $comment = $field->getFieldtype()->getCommentById($page, $field, '26'); if ($comment !== NULL) { $field->deleteComment($page, $comment); } Still not entirely sure what getFieldtype() does, but that is apparently essential. Thank you! Now putting together the complete comment delete button solution, will post in next comment below...
  20. Does anybody know how to use $fieldtypeComments->deleteComment($page, $field, $comment)? See previous post for details. Or how to use functions like this in general. A 'basic usage' is given, but I can't find examples and whatever I try I get errors like 'Call to undefined function' or 'Argument 2 ... must be an instance of Comment' or 'Call to a member function ... on null' or 'Class 'CommentArray' doesn't yet implement method 'makeBlankItem()' and it needs to' or it complains about wrong use of $this because not in context or whatever. Running out of ideas, so please help if you understand this stuff.
  21. How can I use deleteComment()? I posted a question here, but have been trying to figure it out here. Still stuck, so please help.
  22. How can I use $fieldtypeComments->deleteComment($page, $field, $comment) to delete a comment if I have the comment's ID? I have the ID of the comment, but I guess this function needs the entire object? So I guess I first have to use this: $comment = $fieldtypeComments->getCommentByID($page, $field, int $id); Are $page and $field required for both? $page is the page where the comment is on I guess, but where do I get $field? What does return value 'mixed' mean? I see the delete function returns a variable $result, so I'll try to echo that. How should I put this together? Are there examples anywhere? If I echo $page from within my comments.php file, I get an ID that should be usable for the delete function, but I get nothing from $field. What the hell is that $field supposed to be? Where can I get it? This put in a template with the comments produces `Uncaught Error: Call to a member function deleteComment() on null`: $fieldtypeComments->deleteComment( '3156', 'comments', '25' ); I get the same error on any $fieldtypeComments-> function. Should I use FieldtypeComments:: instead? Or $this->...? Or wire()something? Or "declare" a class or globals? Please point me to the basics if you know. This produces a more promising `Uncaught TypeError: Argument 3 passed to FieldtypeComments::deleteComment() must be an instance of Comment, string given`: FieldtypeComments::deleteComment( $page, $field, '25' ); Trying to get a $comment instance (?), this produces another error: `Fatal Error: Uncaught Error: Using $this when not in object context in ...`: $comment = FieldtypeComments::getCommentByID($page, $field, '25'); I see there is also a public function deleteComment() in commentfield.php that doesn't require $field, but requires (?) $notes: I still get `Fatal Error: Uncaught Error: Call to undefined function deleteComment() in...` when I try that in different places in the template. Getting closer. This produces some kind of result: CommentField::deleteComment($page, 25, $notes = ''); Still results in Fatal Error: Uncaught TypeError: Argument 2 passed to CommentField::deleteComment() must be an instance of Comment, int given ... I have also tried $comment, $comment = "25" and "25", but got the same error. What is 'an instance of Comment'? How can I get it? This produces an interesting error: $comment = $page->comments->get('25'); CommentField::deleteComment($page, $comment, $notes = ''); Error: Exception: Class 'CommentArray' doesn't yet implement method 'makeBlankItem()' and it needs to. (in wire/core/WireArray.php line 197) ??
  23. @tires , to use Full Name, or whatever field you need, I now use this in CommentListCustom: And then use {fullname} in your markup instead of {cite}. Continuing my Christmas tradition; upgrading my websites. Last year I got a basic comment system working. This Christmas I want to add edit/delete buttons to comments, absolutely essential for any modern comment system. How can I do that? I have a working comment system based on these CommentListCustom and CommentFormCustom files. 'delete | edit' buttons would go somewhere in CommentListCustom, something like this in the CommentFooter: <div class='CommentFooter'> <p class='CommentAction'> {reply} {permalink} | delete | edit </p> </div> The 'delete | edit' buttons - later icons of course - should only show up for the author of the comment, so they would be wrapped in something like this: if ( $user->isLoggedin() && $user->name == {cite} ) { echo 'delete | edit'; } Using '{cite}' there would probably not work, right? What should I use instead? To delete a comment I would have to identify the comment and then do something like $comment->delete(); somewhere I guess. These comments are not pages I think, so maybe deleting them works differently? Comments are numbered, like id="Comment24" and data-comment="24". How can I target that ID to delete that comment? Or could I just use clever/complicated PHP magic like $this to target the element the delete button is in? Or was that jQuery...? Are we using jQuery anyway to process these actions? I see $this->etc. is used a lot in CommentListCustom. I see there is a 'delete comment' method here. // basic usage $mixed = $fieldtypeComments->deleteComment(Page $page, Field $field, Comment $comment); And for an 'edit' button I would use updateComment()? What values would these functions use? $page would be the page the comment is on I guess. Wouldn't $field be comment field by definition? Would the value for $comment be that ID number? Is there a code example how to use these somewhere? The deleteComment() function in FieldtypeComments.module: Should I just "do" `$this->deleteComment($page, $field, $comment);` and if triggered from within the element it will delete that comment including replies if any? Use jQuery or PHP? Something like this? Or use jQuery as event handler and then somehow trigger a PHP function? I know how to post form data via ajax, but how would that work with `deleteComment($page, $field, $comment)`? The jQuery would send those variable values to a php file with the function that would send a result back to the element I guess. This works to alert the comment ID: Now I can send that comment ID to PHP via ajax and do `deleteComment($page, $field, $comment)`. What should I use for $page and $field? I guess the ID of the page the comment is on, but what is $field supposed to be?
  24. I want to replicate /admin/profile in a styled front-end member account settings page - keep members out of the admin back-end entirely. Is there a quick, built-in way to add those form fields to a template? In particular/for starters/for example Set Password. I already have a working version with a simple form processed like this: if($input->post->updatepass) { $pass = $input->post->pass; if($pass) { if(strlen($pass) < 6) { $winorfail = '<p class="textblock error">Your new password must have at least six characters.</p>'; } else if($pass !== $input->post->pass_confirm) { $winorfail = '<p class="textblock error">Your passwords do not match.</p>'; } else { $user->of(false); $user->pass = $pass; $user->save(); $user->of(true); $winorfail = '<p class=textblock>Your password has been changed.</p>'; } } } But I bet this is horribly unsafe and incomplete. The PW back-end version also asks for the current password for example. Is there a standard "tag" or function or line of code I can use to get the built-in PW processes for these fields? Or should I be able to find the block of code and copy/paste - what keywords should I search on? Or am I on the right track and should I just keep using forms + processing like above? I know how to replicate simple text and textarea field etc. and have even figured out a working image upload. But how can I replicate a Repeater field on the front-end, with all the nice UI magic I get on the back-end? How could I get image upload on the front-end with the same UI as in the back-end? Edit: I found a few other questions about Repeater fields in front-end forms here and here. This looks promising. I'll try that and post findings on that thread.
×
×
  • Create New...