Updated 034 How to add Custom Buttons in JCB to your component Admin Area (markdown)

Amigo 2019-07-20 11:47:39 +02:00
parent 714bd0de18
commit 23ab1e92c9

@ -45,11 +45,15 @@ First thing is to get the values. Having the data, check whether the values that
[00:10:39](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m39s)
What is being done the model area? Do keep in mind that if the model is unsuccessful, something needs to be done, if the data is set, but the model is not being successful, something needs to be done, and if the data is not set, something needs to be done.[00:10:55](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s) Those are the areas in which some messages can be added that needs to be returned to the user, to inform them what is happening. In the model, the task gets performed, and when the goal is achieved, return 'true', if it failed, return 'false', and then that would trigger the messages in the controller. This is just giving a basic overview of setting up some Model Controller connected with a button. <<<<<
What is being done the Model area? Do keep in mind that if the Model is unsuccessful, something needs to be done, if the data is set, but the Model is not being successful, something needs to be done, and if the data is not set, something needs to be done.[00:10:55](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m55s) Those are the areas in which some messages can be added that needs to be returned to the user, to inform them what is happening. In the Model, the task gets performed, and when the goal is achieved, return 'true', if it failed, return 'false', and then that would trigger the messages in the controller. This is just giving a basic overview of setting up some Model Controller connected with a button.
### Adding Code
I'm going to add some of this code in here, you are welcome to pause the tutorial and then drop down whatever [00:11:37](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m37s) you'd like to reuse, but the reality is you should actually be able to do this without my help. Therefore if you don't know what I'm doing here, then please go Google a little more. Go find out some more tutorials elsewhere how to create model and controller relationships in Joomla using it's API. The other reality is you can open this model and controller of the specific view [00:12:11](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m11s) in your IDE and in there you can see how the code is added, and what is happening, and how is it done. You can educate yourself that way as well. I'm going to add the code in. I've just added some code that you can also reuse and this basically, if the work has been done, we will let the user know it's done. If work wasn't done we also let him know. If we couldn't even detect the required values, then we just throw a major error and [00:12:51](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m51s) quit out. That is really the controller. I didn't populate much of the model because you should design your own logic, but I do return true so to give this first message.
[00:11:30](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m30s)
Some of this code is going to be added in here,(It will be beneficial to study some more tutorials on how to create Model and Controller relationships in Joomla using its API, or you can open this model and controller of the specific view in your IDE and in there you can see how the code is added, and what is happening, and how is it done). [00:12:11](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m11s) I have added some code that you can also reuse. If the work has been done, If it have not been done the user will be informed that it has not been done. If the required values had not even being detected, then a major error is passed and quit out.[00:12:51](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m51s) That is the Controller. Not much of the model is populated, since the design is left to your logic. Return 'true' so to give this first message.<<<<<<<<
### Demonstration of Adding A List Button