diff --git a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md index c350ad0..674d818 100644 --- a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md +++ b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md @@ -23,13 +23,19 @@ There is a admin view called 'Experts'. For example: If there is a need in this A lot of JavaScript may be noticed on this page and here(See video) has this job tracking extension been written. If for example a new job order needs to be created, then it can be indicated whether it is a new client or a existing one. If it is an existing, simply select from the list. [00:08:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) If it's new, click 'A new Client'. All the details of the user can be entered and when 'save' is clicked, it creates the user, stores the data in the user table, but not in the job order table and deletes all these values (the job order table never stores any user values in the relation of this job order). -If this closed, open a 'New client'. The same values can be seen. [00:08:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m44s) This is another way to integrate this whole user integration. <<<<<<<<<<<<<<<<<<<<<, - - +If this closed, open a 'New client'. The same values can be seen. [00:08:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m44s) This is another way to integrate this whole user integration. ### Make Use Of The Ajax Concept -So let me illustrate some of or let me show you some of the code that I used to do that. [00:09:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m26s) So we are back in the experts view. As I've done before I previously, in other tutorials explained how to make use of the Ajax concept within Component Builder. Now for those of you that like to understand what's going on let me give you a quick runover at the code level. Within every component that makes use of Ajax, a model, and a controller is created. The controller is named Ajax.json.php and the model is named [00:10:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m04s) Ajax. Let me open the model, let me also open the controller. As you can see the controller basic fires off the register tasks within the construct method. And then it adds the tasks into a switch, and tries to run the task. Also in [00:10:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m31s) the model it gets the model Ajax, and then runs the method that basically corresponds to the task. And so that is how it runs. + + In previous tutorials it had been explained how to make use of the Ajax concept within Component Builder. Here is a quick overview for those that would like to understand what happens at code level. How does the code look which had been used for a Ajax? [00:09:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m26s) + + Return to the Expert view. + + Within every component that makes use of Ajax, a model, and a controller is created. The controller is named 'Ajax.json.php' and the model is named 'Ajax'. [00:10:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m04s) Open the model and the controller. As may be seen the controller gives the register commands within the construct method and adds the tasks to a switch, and makes a attempt to run the task. [00:10:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m31s) In the model it gets the model Ajax, and then runs the method that corresponds to the task. <<<<<<<<<<<<<<<<<<<<<<< + + + It uses the Joomla's default filtering method in the way that it gets values that are being posted. And then value dates that those values actually are there. Then sends the values over to the model. [00:11:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m05s) Now that's looking at it from a code side. If you look at the model it simply shows you various methods. Some of them are protected, and some of them are public. Those(getcreateuserfields) are usually the ones that gets called from the controller once the Ajax gets the verification level and it's verified. Here is the createuser class. [00:11:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m31s) We first check whether this user, (now this is custom script I mean this I wrote custom, component build does not write this) so basically when you go back to the user interface, you will see that if I scroll down here, create user fields, then there's create user. You see that I wrote this right here, and that basically gets placed into the model. [00:12:07](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m07s) So that's the Ajax method. In that Ajax input I annotate the specific tasks, the task name, and specific variables, and again the method name. You could have different method names from task names. What should be validated, whether it's integer, float or whatever. And if there's no value, what is the value by default. So this is where you set up there basically the controllers information. [00:12:39](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s) And then here your customisely write your script. So basically create user gets data and seems from what view is it, then validates with this current login user has the permission to the experts area. Then it converts the data because it's a json set of datasets that I'm sending across. Checks whether it's an array, does some other checks.