modifiedcontent
Members-
Posts
286 -
Joined
-
Last visited
Everything posted by modifiedcontent
-
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
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... -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
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... -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
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. -
How can I use deleteComment()? I posted a question here, but have been trying to figure it out here. Still stuck, so please help.
-
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
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) ?? -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
@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? -
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.
-
I'm trying to use an RSS feed with an unusual format that works fine in browsers, but PW's field checker keeps rejecting it. I've tried several variations of this: ... /__rss/website-scheduled-content.xml?input={"sectionAlias":"process"} ... /__rss/website-scheduled-content.xml?input=%7B%22sectionAlias%22%3A%22process%22%7D Any ideas how to get this through? Edit: Nevermind, I see the HTML Entity Encoder on the field has an option to allow single/double quote characters. That fixed it.
-
Can WordPress and ProcessWire coexist on same site?
modifiedcontent replied to Lance O.'s topic in General Support
You can use the API to integrate content from Processwire into Wordpress. Haven't thought this through, can provide more details later, would be messy anyway... -
I want to quickly remove the picture upload button from Ckeditor - it doesn't play nice with Processwire or does it? I appreciate this thread, because I am always very confused how to customize the editor, although I have done it several times before. Where are these settings? I have to edit directly in a Ckeditor js file somewhere, right? Or does Processwire have a built-in settings editor somewhere? I see there is some explanation here... That makes customizing the editor for PW fields not that difficult; settings are in the Input tab for the field that uses Ckeditor. But I see I am using a second Ckeditor on the front-end, that I'll have to customize in the js file I guess. I should figure out how to use the editor that comes with PW instead...
-
Thanks for the response @Jan Romero. I was looking in that direction. I think 'profile-edit' is for admin/profile/, which is based on the system 'user' template. I use another 'profile' template for pages created when members register with the site. Today I have tried to figure out if I could replace that 'profile' template by the 'user' template, but I can't make it work for some reason. I can just keep using 'profile' I guess and get all the content from 'user' anyway, but is there any way to edit the template of /admin/profile/? The use of the (user)name instead of First Lastname annoys me. And I'd like to replace the Processwire logo/icon with the site + homelink etc.
-
I am working on a membership system. I have a parent page 'members' and until now used a child page 'profile', but am now trying to replace the 'profile' template with the 'user' system template - makes more sense, no? The 'user' template won't show up as a template option in page edit Settings. I have checked Family in the template setup; 'members' is the allowed parent for the 'user' template and 'members' has 'user' as allowed template for children. 'Don't allow pages to change template' in Advanced is also off for all involved templates. What am I missing? Can the system 'user' template even be used for pages or does it work differently?
-
I want to give members of my site access to their profile page edit in admin, but I don't want them to go up the tree and start editing other members pages - which is what could happen if I control access by the template 'profile' only. How can I make sure members can only edit their own profile page? In the profile template, for the front end, I have something like `if ( $user->isLoggedin() && $user->name == $page->name )` to restrict edit access to the page owner. In the back end there are parameters on the URL, like admin/page/edit/?id=1388 How can I target that? I can get the currently logged-in user's profile page ID; if they are trying to edit another page ID, they should be blocked/redirected. Can I add something in admin.php to achieve that? I see Ryan Cramer has a PageEditPerUser module, but it is very old, very beta and requires to enter allowed pages manually. AdminRestrictBranch seems more stable and has a Custom PHP option - trying to figure that out now...
-
Is there a way to hide the Settings tab by role?
modifiedcontent replied to modifiedcontent's topic in General Support
Found a solution based on @Fokke's solution from 2015. Adding the following in admin.php, before the line `require($config->paths->adminTemplates . 'controller.php');` gets me the behavior I needed; Settings only shows up for the SuperUser: function hideSettingsTab(HookEvent $event) { // Get the page being edited $page = $event->object->getPage(); if ( !wire('user')->isSuperuser() ) { $page->template->set('noSettings', 1); } } $wire->addHookBefore('ProcessPageEdit::buildForm', null, 'hideSettingsTab'); This solution is easy to adapt for whatever your needs are.- 1 reply
-
- 3
-
Is there a way to hide the Settings tab in admin/page/edit by role? I am fine-tuning my members view. Processwire is such a nice system, so much access control by fields and templates etc. But I can't figure out how to hide the Settings tab. I want members to be able to edit their profile page, but not change the "slug", template, publication status, etc. Using access/roles/edit I think I can block access to 'change template' with 'revoke from: template', but the template still shows up in Settings, not editable with or without revoke - I made that unchangeable somewhere else. The slug name is editable and really shouldn't be for members. I see there is a module for this - haven't tested yet... Is that still the way to go or is there a build-in solution?
-
Connecting to external API from Processwire
modifiedcontent replied to modifiedcontent's topic in API & Templates
@Rudy, thanks for the idea. I tried this, but it didn't make any difference, even after clearing caches etc. Edit: I figured it out. In the script I "called" the API with this: $initAuth = new ApiAuth(); When I should have used: $initAuth = new Mautic\Auth\ApiAuth(); To "declare" (?) the namespace. -
I am trying to connect with an external API, from marketing automation application Mautic on the same server, from a template in Processwire, with something like this: require '/serverpath/vendor/autoload.php'; use Mautic\Auth\ApiAuth; use Mautic\MauticApi; $initAuth = new ApiAuth(); This works in an empty test page outside of Processwire. Trying to use it from a template within Processwire I get this error: How can I make sure the script looks for Mautic's ApiAuth in the correct place? Mautic's autoload.php is included in the page successfully; I have checked that.
-
I don't think my template code has anything to do with it. Here is a minimal version of the template that still has the same problem: Not only ""/>" is inserted in the html output. When I add a link to my $page->summary field, all the text after the <a href=...> opening tag is copied (?) and inserted after the body tag with most of the head including <title>. I say copied, because the block of text with URL also appears in the correct place. When I remove the link from 'summary', everything looks as it should, no crap inserted after the body tag. Edit: I found it. I had the following in head: <meta name="description" content="<?php echo $page->summary; ?>" /> That works fine with plain text, but breaks when you add html like a URL to the summary field. Or is there a proper way to filter it for meta content?
-
Uninstall of this module doesn't work: I only installed it, because module refresh gave a warning about a missing file from NewsletterSubscription - probably left-over from another install/uninstall attempt long time ago. Is there another safe way to remove/uninstall modules?
-
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
Thanks @ukyo, but what is that supposed to do? I plan to have my custom files in templates/forms. What difference would putting them in templates/extend or site/src make? Why site/src - is adding folders outside templates a good idea? Those classLoader lines apply to the entire folder, not a specific file? Are the general principles how to work with classes and customize modules in Processwire explained anywhere? I haven't been able to find it. This produces a result: CommentListCustom.php copied from the wire module into my templates/inc folder. The custom file is now used to display the comments. I can now make edits in that file to somehow change {cite} to the commenter's full name. Wtf is {cite} anyway? It's not a PHP variable. How is it defined? How can I redefine it? I can't do something like {cite} = $users->get({cite})->fullname; What syntax should I use? What rules apply to these {something} "thingies"? Why does this produce Fatal Error Uncaught Error: Call to a member function get() on null? This seems to work though: For the form it works the same of course: Then make edits in CommentFormCustom.php as required. In my case I added 'hidden' to the cite and email input fields, so logged-in users only get a text field, don't have to enter any other info - the module enters logged-in user name and email in the hidden fields if you remove/turn off all the cookie stuff. Two next issues to solve: 1. Is the upvote/downvote system cookie-based? What would it take to turn that into logged-in user ID-based? Or is that the default if I turn off cookies/remove cookie javascript? 2. Users will expect a way to delete and edit their comments. Has anyone done that? Suggestions welcome. -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
I can't figure this out. I have added a comment.php file in my templates/forms folder with the following: With this in the page's template: This doesn't do anything - the echo from comment.php doesn't show up anywhere. I am not an experienced/full-time PHP programmer. It is not obvious to me what is going on in these scripts. @ukyo, what does '// do your customizations ' look like? Could you or anyone else give a basic example? Should I copy entire functions from CommentForm.php or CommentFormCustom.php (?), change a few things within those functions and then those customizations will replace the functions in /wire? Should I rename the functions? Or does whatever I put in '// do your customizations ' run after CommentForm.php in /wire - adding not replacing? I also tried to follow the instructions in CommentFormCustom.php, but did not understand any of it. I've copy/pasted different parts and functions from that file into my custom comment.php, but could not get a result with anything. Continuing with this tomorrow... Any hints very much appreciated. -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
Thanks @ukyo. I'll try this in my next steps. In the meantime I have found out why my threaded comments - 'Reply Depth' etc. - didn't work. Threaded comments relies on jQuery in comments.min.js in wire/modules/Fieldtype/FieldtypeComments/ I load jQuery in my head with these lines: I think Processwire has jQuery "built in", but have always been confused how to use it. When I just remove my lines from head, all my jQuery breaks. If I already have jQuery in my site, why doesn't the jQuery in the module work? Does Processwire require a specific version of jQuery? The module's jQuery works fine when I copy it from comments.js to my template and replace jQuery with another var: I have also removed all the cookie stuff from the module's javascript. I think without it the comment form name+email fields are prefilled with data from the logged-in user, which is what I needed. Is there a way to add the Reply link with the foreach($page->comments as $comment) method? If not, I'll figure something out with @netcarver, @flydev ?? or @ukyo's suggestions - thanks! -
FieldtypeComments - how to customize
modifiedcontent replied to modifiedcontent's topic in General Support
Thanks @netcarver. So 'presets' is an array somewhere that contains 'cite' and other things? Username is OK for the comment form, because comments will only be open to logged-in members. The module enters the logged-in users name and email address, so I can just hide those fields - or is there a way not to require them at all? The updated second method in my original post also produces the result I want, minus the Reply link. That Reply link doesn't seem to do anything special anyway; comments are all created on the same level, Comment1, Comment2, Comment3. I am now mostly puzzled by how to make threaded comments work - 'Reply Depth', reply-to-comment. Edit: Another problem; where does the module get the name + email address that are prefilled in the comment form? They are not consistently the name + email from the logged-in user as I assumed. When I test logged-in with different accounts, only the name + email of the first account I tested with show up in the comment form. Is there a way to just let the comment form take the name + email, or just ID, of the logged-in user? Edit 2: Javascript sets a persistant cookie for whoever posts a comment? I guess I should replace that with Javascript that enters the logged-in user's name+email then. Or is there any way via PHP without editing the module core files? -
Render Comments with options is this: {cite} inserts the username. I want to display the commenter's Firstname Lastname instead - I have a field for that called 'fullname'. Where is {cite} defined? How can I change it? This should be functionally the same (?) and would give me control to define and change lots of stuff, including "cite" and adding profile picture etc.: But with this, the 'Reply' link is missing from the comment. How can I add that 'Reply' link and make sure those replies-to-comments or replies-to-replies-to-comments are stored in the proper way? Or will that get me into a hopeless mess and should I just stick to the render method with a simple way to make {cite} render the full name instead of a username? edit: I see the comments just end up on the same level anyway, with either method - Comment1 Comment2 Comment3. 'Reply Depth' is set to '2' in the Comments field settings. Does threaded comments not work?