SamC Posted December 15, 2017 Share Posted December 15, 2017 I was going to add comments to my site and wanted to use disqus. I looked through the manual adding of this but thought this might be a good opportunity to learn how to make a module as I can't find one in the directory. Was thinking having a few fields or something, where config options can be set and they are then output somehow into the JS embed code. Not really sure about how any of it would work yet but gotta start somewhere. You'll notice on the disqus page that many other CMSs have dedicated plugins/modules to install it, so I'm looking to create the PW one. The manual instructions for disqus are here: https://help.disqus.com/customer/portal/articles/472097-universal-embed-code My immediate problem is, what category is a module like this? And what class would I extend? 'extends Process', 'extendsWireData' etc. It's not clear to me on the api page how you'd choose and reading the code from the base classes probably wont switch on any lights here. https://processwire.com/api/ref/module/ Maybe I'm biting off a little more than I can chew, but what the hell, it'll be a good learning experience, and maybe produce something useful at the end of it. I'll be digging into @bernhards process module tutorial this weekend but I don't think this is a process module. 3 Link to comment Share on other sites More sharing options...
kongondo Posted December 15, 2017 Share Posted December 15, 2017 Try these http://processwire.com/api/modules/ 1 Link to comment Share on other sites More sharing options...
dragan Posted December 15, 2017 Share Posted December 15, 2017 I didn't integrate Disqus so far in any PW site (or anywhere else, for that matter), but I guess this very fine tutorial should get you going: https://abdus.co/blog/creating-a-simple-and-configurable-module-for-processwire/ Especially the "Building a configuration page" chapter. 1 1 Link to comment Share on other sites More sharing options...
SamC Posted December 15, 2017 Author Share Posted December 15, 2017 Some great resources to get me started, thanks! Following this one at the moment: https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/ One thing, how I do I see changes in the module as I go along? When I make a change, I tried clearing cache but changes are not reflected, specifically, the page created in the getModuleInfo() method, for me at '/login/test/'. I changed the path in my code but the only thing that's worked so far was uninstall > reinstall. Is there an easier way? Link to comment Share on other sites More sharing options...
rick Posted December 15, 2017 Share Posted December 15, 2017 11 minutes ago, SamC said: One thing, how I do I see changes in the module as I go along? When I make a change, I tried clearing cache but changes are not reflected, specifically, the page created in the getModuleInfo() method, for me at '/login/test/'. I changed the path in my code but the only thing that's worked so far was uninstall > reinstall. Is there an easier way? When you navigate away from the page that uses your process, any changes should be reflected the next time you visit that page, unless you are modifying the module config fields. I have phpstorm open with my process module, and the module installed on localhost. When I make a change to the code, I simply select another menu option, such as pages, then re-select my process module menu and the changes are immediate. 2 Link to comment Share on other sites More sharing options...
Sergio Posted December 15, 2017 Share Posted December 15, 2017 (edited) Beware of the large JS load that comes with Discuss, that's why I load it only if the user clicks the "Comments" button. It's possible to show the current comment count, calling the discuss API, but I didn't want it. Example page: https://ricardo-vargas.com/podcasts/think-about-how-to-connect-your-strategy-design-with-your-ability-to-deliver-or-pay-the-price/ Edited December 15, 2017 by Sergio Add example 3 Link to comment Share on other sites More sharing options...
SamC Posted December 15, 2017 Author Share Posted December 15, 2017 @rick yeah, I can see the changes now on the page when I change things inside the ___execute() methods. The part that I was changing was here: public static function getModuleinfo() { return [ "title" => "Simple admin example", "summary" => "No need to be afraid of building custom admin pages.", "author" => SamC", "version" => 1, // page that you want created to execute this module "page" => [ // your page will be online at /processwire/simple/ "name" => "test", // <<<<<<<<< I CHANGED THE PATH HERE // page title for this admin-page "title" => "Hello", ], ]; } Had to uninstall and reinstall for this change to be reflected. Anyway, getting sidetracked as usual. 1 minute ago, Sergio said: Beware of the large JS load that comes with Discuss, that's why I load it only if the user clicks the "Comments" button. It's possible to show the current comment count, calling the discuss API, but I didn't want it. I was thinking of just having the comments button, no need to load it up all the time. Not sure how people would even use it but I needed a reason to make a module, and here it is 1 Link to comment Share on other sites More sharing options...
rick Posted December 15, 2017 Share Posted December 15, 2017 3 minutes ago, SamC said: Had to uninstall and reinstall for this change to be reflected. Anyway, getting sidetracked as usual. Module refresh will show any changes you make to the info without having to re-install it. 2 Link to comment Share on other sites More sharing options...
ottogal Posted December 16, 2017 Share Posted December 16, 2017 I really would hesitate to use or propagate the use of disqus. Some links: The Hidden Price of Using Disqus Why I killed Disqus Commenting on my site You can easily find more worth considering... 5 Link to comment Share on other sites More sharing options...
SamC Posted December 16, 2017 Author Share Posted December 16, 2017 Ouch, this could be a problem. I haven't looked at the built in PW comments and they might work. However, I still need to make a module! 1 Link to comment Share on other sites More sharing options...
bernhard Posted December 17, 2017 Share Posted December 17, 2017 22 hours ago, SamC said: However, I still need to make a module! I'm sure you'll love it I'm glad you chose my blogpost as a tutorial but keep in mind that this was intended to show how to build process modules. I guess there are better resources for regular modules out there edit: just saw you already mentioned it: yes, you don't need a process module for that. i created the tutorial because there are lots of tutorials and examples of how to create regular modules but only very few that cover process modules. creating your own fields (fieldtype/inputfield modules) is a little more complex. i would recommend you start by creating a simple module that loads some javascript, hooks into something (like modifying markup of other fields) this is a simple example of one of my first modules that covers lots of basic principles and that you can use for learning: https://github.com/BernhardBaumrock/TemplatePreviewImages (note that $config->scripts->add() only works when the fields are not ajax loaded) 1 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