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

Amigo 2019-07-22 09:10:09 +02:00
parent 71183aa7fc
commit 2aab8fce8b

@ -51,13 +51,13 @@ What is being done the Model area? Do keep in mind that if the Model is unsucces
[00:11:30](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m30s) [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 may be reused. If the work has been done, But 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.<<<<<<<< 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 may be reused. If the work has been done, But 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
### Demonstration of Adding A List Button [00:13:08](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m08s)
Then we'll go to the IDE change it to false again to demonstrate the response. And play around with the code in the IDE [00:13:17](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) to give you a feel of how to approach it from that direction. We going to save this, then go and compile it. Then install the new compiled version. Open the component. Go to Looks. We can see how our test button is still here, if we click it, it still takes us to the dashboard. [00:14:01](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m01s) Let's open the test. We have a new button here Worked. If you click it now, it'll give us the work was done, because our method returns true. Let me open the IDE. Looking at our controller in the back end. [00:14:32](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m32s) First we going to open the list one(looks.php) which is the plural version. We see getTested was added, and there is our little method. If we go to the edit singular one(look.php), [00:15:00](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m00s) and getdone. Here is our method, and all our functions. And JCB has added the script to the translation text. Everything here looks fine. If we go to the model, we open the look model, we'll see that [00:15:22](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m22s) it has a new method added. So just after getTable, here it is added our little method. So I will add this to false, and save. [00:15:47](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m47s) Go back to Joomla and then click our button again. And now it says work was not done, because the method returned false. So if we change that to true again, and save then it should work. Then the IDE is changed to false again to demonstrate the response. Play around with the code in the IDE to get the feel of how to approach it from that direction. Save this(See video), then go and compile it and install the new compiled version. Open the component. Go to 'Looks'. The test button is still here, if it gets clicked, it still returns us to the dashboard. [00:14:01](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m01s) Let's open the test. Here is a new button 'Worked'. If it gets clicked, it will indicate that the work was done, because the method returns 'true'. Open the IDE. Look at the controller in the back end. [00:14:32](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m32s) First, open the list one(looks.php) which is the plural version. It may be seen that 'getTested' has been added, and there the little method may be seen. Then go to the edit singular one(look.php), and getdone.[00:15:00](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m00s) Here is the method, and all the functions. JCB has added the script to the translation text. Everything here(See video) looks fine. Go to the model, open the 'Look' model, it may be seen that it has a new method added.[00:15:22](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m22s) So just after 'getTable', is the little method added. So add this to 'false', and save. [00:15:47](https://www.youtube.com/watch?v=VyBxWpJWb40&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m47s) Go back to Joomla and then click that 'Work' button again and it says work was not done, because the method returned false. So if that is changed to 'true' again, and saved then it should work. <<<<<<
### Demonstration Adding A Button Inside Of Edit View ### Demonstration Adding A Button Inside Of Edit View