Spinbox Posted February 3, 2023 Share Posted February 3, 2023 Hi @kongondo, I have followed the guideline how to set up an addon for Padloper. The file is located in /site/templates/padloper/addons/CSVImporter/CSVImporter.php with classname CSVImporter It has the required methods. Any idea how to get this to be detected? Link to comment Share on other sites More sharing options...
Spinbox Posted February 3, 2023 Author Share Posted February 3, 2023 Found out, I had a typo in renderViewURL (no caps URL). Nice to have those debug messages present ? 1 Link to comment Share on other sites More sharing options...
kongondo Posted February 3, 2023 Share Posted February 3, 2023 Glad you got it sorted! Would love to see some screenshots if that's possible, just as a showcase of addons, thanks ?. Link to comment Share on other sites More sharing options...
alexm Posted June 25, 2023 Share Posted June 25, 2023 Can someone tell me where I'm going wrong. I'm a little lost with the MyAwesomeAddon documentation. <?php namespace ProcessWire; class TestAddon extends WireData implements PadloperAddons { /** * @var string */ protected $renderViewURL; public function __construct() { $this->renderViewURL = 'go-cardless'; } /** * Returns addon type. * * Must be one of Padloper pre-defined types. * * @return string */ public function getType() { return 'custom'; } /** * Returns addon class name. * * @return string */ public function getClassName() { return "TestAddon"; } /** * Returns user-friendly title of this addon. * * @return string */ public function getTitle() { return "TestAddon Title"; } /** * Returns short description of this addon. * * @return string */ public function getDescription() { return "TestAddon description here."; } } Link to comment Share on other sites More sharing options...
alexm Posted June 25, 2023 Share Posted June 25, 2023 /** * Returns addon type. * * Must be one of Padloper pre-defined types. * * @return string */ public function getType() { return 'custom'; } If I return 'payment' it shows in the addons table, but I was following the docs which says to return 'custom' Link to comment Share on other sites More sharing options...
kongondo Posted June 25, 2023 Share Posted June 25, 2023 Morning @alexm, Apologies for the confusing docs (and perhaps naming issues). All non-payment addons must return 'custom' for getType(). Payment addons, even custom ones, are not defined as 'custom' addons. They are defined as payment addons and must return 'payment' for getType(). So, the idea of 'custom' does not mean 'third-party' or 'non-core'. Instead, it means the addon does something that is not necessarily a feature of Padloper, i.e. it does something custom. Since 'payment' is something that is a feature of Padloper, even third-party payment modules are not considered 'custom' since their function/role is to do something that is part of the core function of Padloper, i.e. payments. Hope this makes sense. Will revise docs. 1 Link to comment Share on other sites More sharing options...
alexm Posted June 25, 2023 Share Posted June 25, 2023 Morning @kongondo, but ignoring me setting the renderViewURL property to 'go-cardless', say I want to make, for the sake of argument, a discount code addon - what would I set the returned value of getType() to? 'custom' doesn't work for me and if I set it to that, nothing shows in the addons table Happy Sunday mate Link to comment Share on other sites More sharing options...
alexm Posted June 25, 2023 Share Posted June 25, 2023 Hmm when I add a bar dump in PadloperProcessRenderAddons.php before the if statement on line 460 it says that the renderViewURL property is null. Got any pointers for me haha. Sorry. Link to comment Share on other sites More sharing options...
alexm Posted June 25, 2023 Share Posted June 25, 2023 Got it! Needs to be public property public $renderViewURL = 'view-name'; Link to comment Share on other sites More sharing options...
kongondo Posted June 25, 2023 Share Posted June 25, 2023 5 hours ago, alexm said: say I want to make, for the sake of argument, a discount code addon - what would I set the returned value of getType() to? Hey @alexm, the value of that would have to be 'custom'. All non-payment addons must be of type 'custom'. 4 hours ago, alexm said: Got it! Needs to be public property Yes. Sorry about that. I need to state that in the docs. Does this mean your question above about 'getType()' is now sorted? Thanks. 1 Link to comment Share on other sites More sharing options...
alexm Posted June 26, 2023 Share Posted June 26, 2023 18 hours ago, kongondo said: Yes. Sorry about that. I need to state that in the docs. Does this mean your question above about 'getType()' is now sorted? Thanks. Correctamundo. This resolves this matter thank you sir 1 Link to comment Share on other sites More sharing options...
alexm Posted June 26, 2023 Share Posted June 26, 2023 Good evening @kongondo, just a quick one (hopefully). Sorry in advance, I'm not much cop with module development etc. I'm just wondering how I access the addon page and 'padloper_settings' field name from the TestAddon class. I note the setAddonPage() method in the custom addon docs but not sure/understanding entirely it's purpose or if this is used to retrieve them? But effectively I've created a method saveConfigurations() which gets passed the fields array and JSON encoded ready to save to the 'padloper_settings' field. Now I just need to figure accessing the page object and field name in the right manner rather than hard coding. Thank you in advance for any assistance as always. 1 Link to comment Share on other sites More sharing options...
kongondo Posted June 27, 2023 Share Posted June 27, 2023 Hi @alexm, 21 hours ago, alexm said: if this is used to retrieve them? Exactly. An example: <?php namespace ProcessWire; public function setAddonPage(Page $page, string $addonSettingsFieldName) { // here we assign these variables to class properties for convenience // you don't have to do that // you can use $page directly to get your settings using 'addonSettingsFieldName' $this->addonPage = $page; $this->addonSettingsFieldName = $addonSettingsFieldName; // -------- // EXAMPLE $addonSettingsJSON = $page->get($addonSettingsFieldName); bd($addonSettingsJSON, __METHOD__ . ': $addonSettingsJSON at line #' . __LINE__); if(!empty($addonSettingsJSON)){ $addonSettingsArray = json_decode($addonSettingsJSON,true); // do something with $addonSettingsArray } } I thought I had a hello world addon example in the demo projects. Looks like I don't. I'll add that to my TODO. 1 Link to comment Share on other sites More sharing options...
alexm Posted June 27, 2023 Share Posted June 27, 2023 @kongondo Hmmm, one still doth not follow. I'll private message with further deets I think. There is no rush or obligation to help if you are busy (which I know you are), but I think you'll see what I'm going for ? 1 Link to comment Share on other sites More sharing options...
alexm Posted June 29, 2023 Share Posted June 29, 2023 Long and short of this is thank you @kongondo for helping me to rectify the issue with my custom addon (which I will happily share) once done. It was due to me not correctly setting up the necessary methods and properties before installation, so one I knew that my custom addon's main class file was correct, per @kongondo's advice, I simply de-activated and re-activated the module and I am able to access the addone page and fieldname as expected. Big thank you as always dude! 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