formmailer Posted November 8, 2017 Share Posted November 8, 2017 (edited) Hi, I am trying to style the comments form (and comments list) to match the rest of the site. I know that it's possible to edit the CSS file for the comments module, but I would rather add my existing classes to the fields, instead of making another css file containing the same CSS styling. I use the following to render the form: $page->comments->renderForm(); Is there an easy way to add the CSS classed to the fields? //Jasper Edited November 10, 2017 by formmailer Solved Link to comment Share on other sites More sharing options...
Juergen Posted November 9, 2017 Share Posted November 9, 2017 Take a look at this post (https://processwire.com/talk/topic/17263-custom-comments-form-and-list-styling/?do=findComment&comment=151627): You can copy the comment files from wire/modules into the module folder of your site folder (site/modules) and there you can change your CSS classes and the markup too. I think this is the best approach to adapt the comments output to your needs. You dont need to hack anything and it will not be overwritten during updates. 1 Link to comment Share on other sites More sharing options...
formmailer Posted November 9, 2017 Author Share Posted November 9, 2017 Hi! Yes, I thought about doing that, but I was hoping there was a shortcut to this. A risk (even if it's a minimal one) is that future core updates could break the module. I was hoping there would be a way to change classes without modifying the module. But if this isn't possible I'll go with the copied & modified module. //Jasper Link to comment Share on other sites More sharing options...
Juergen Posted November 9, 2017 Share Posted November 9, 2017 Another approach would be to add the CSS classes with Jquery onload, but you are also not aware of changes in the future. I use the first method for years now and I had no problems. I dont think that there will be major changes taken in the future. At the moment you could only change some attributes of the form tag, but not for the inputs. 1 Link to comment Share on other sites More sharing options...
formmailer Posted November 9, 2017 Author Share Posted November 9, 2017 I managed to build the whole site without using Jquery, for speed optimization, so unfortunately the Jquery option is no alternative. I will go for the copy solution. Thank you for your help! 1 Link to comment Share on other sites More sharing options...
Juergen Posted November 9, 2017 Share Posted November 9, 2017 Another idea would be to use https://github.com/sunra/php-simple-html-dom-parser library, works like Jquery, but its only PHP and run server side. You can manipulate the output of fe comments->render function and you can add classes to it. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now