Updated 024 How to integrate the Create User Helper Method in your Components (markdown)

Amigo 2019-07-01 10:26:29 +02:00
parent 05c3d29901
commit 8ca17d1dbe

@ -33,13 +33,12 @@ It uses the Joomla's default filtering method in a way that it gets values that
### Global Helper Class ### Global Helper Class
[00:13:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s)Here is that Global Helper class and methods being used.(See video) A number of Custom Methods may be seen which are [00:13:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s)Here is that Global Helper class and methods being used.(See video) A number of Custom Methods may be seen which are
available in that class. It has been added as freebies and should not necessarily always be used. If anyone can improve on those methods, please make a pull request and changes can be done.<<<<<<<<<<<<<<< available in that class. It has been added as freebies and should not necessarily always be used. If anyone can improve on those methods, please make a pull request and changes can be done. Once the required data had been collected(See video), and getting that same 'method', a 'Create User' is done.
[00:13:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m55s) Then get a result('$returned'), and if it's not the correct result it should be dealt with accordingly. If it is the correct user it may be added to the user group. That is something that Create User does not do. There is a user group setup in the component. [00:14:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m17s) The user group needs to be set into the correct user group. The return message will indicate if it has been an error or a success. Lower down(see video) is the error message. [00:14:45](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s)<<<<<<<<<<<<<<<<<<<<<<<<<
Then over here(see video) once we've become very sure that we've got enough data on the right data. We basically get that same method and we need to create user. [00:13:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m55s) We get result. And if it's not the correct result we deal with it accordingly. And if it is the correct result we add the user to the user group. That's something that create user does not do. We have a user group setup [00:14:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m17s) basically in the component. We get that user group, set into the correct user group. This is a return message, if it's an error or it's a success. So down here(see video) is the error message. If it's successful this is what we do if it's unsuccessful this is what we do. [00:14:45](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m45s) That's just a quick look, I mean obviously we can pause this video, and look at what I have done.
### Get User Field ### Get User Field
And then here is getUser when the page loads initially. We get the id, we get the data. Packs it into some html and sends it off. This is the php site obviously where we do this create user. Then there is a ajax [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15rm16s) site in Javascript. In the JavaScript when the page loads, you would get user with the user id, we get the user id from the field. And then it loads that data that you saw. Basically shows you that is the data it loads. And that data can be edited except over here(username). [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) You cannot add numbers in the username but you can do that(see video) and it will update it as you see and will say that it is updated. Obviously if there is a error with the email already used or something it will also give you an error. And this is all part of how we basically have setup the JavaScript. I've just added Javascript to the view file. Here is getuser on the server site, and there is the function. [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) I have two functions usually one that deals with waiting and then eventually setting up the data into the view. Here is the one making the call. This is how the call structure would usually look in index.php?option=your components name, and the task which must go to the Ajax controller. And then this(getuser) is the task. [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) And here you can stipulate what format you would like the result set returned in. If you want the result set returned raw, which in is sometimes the case, there is if you look here, there is a raw variable. You can just set the raw variable to true. Then it will give you the results set just like that without braces around them, [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) or a call back or anything. You see when you make calls from JavaScript, it usually wants this call back to be added. If you make calls from other JavaScript libraries, you might just want the braces around it. But if you want it raw which also is often the case you just add the variable raw to the URL = true and then end up passing it back to you with this. So that's a little heads up on Ajax function. [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s) The format must stay json, that's important. And then here is getUser when the page loads initially. We get the id, we get the data. Packs it into some html and sends it off. This is the php site obviously where we do this create user. Then there is a ajax [00:15:16](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15rm16s) site in Javascript. In the JavaScript when the page loads, you would get user with the user id, we get the user id from the field. And then it loads that data that you saw. Basically shows you that is the data it loads. And that data can be edited except over here(username). [00:15:51](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m51s) You cannot add numbers in the username but you can do that(see video) and it will update it as you see and will say that it is updated. Obviously if there is a error with the email already used or something it will also give you an error. And this is all part of how we basically have setup the JavaScript. I've just added Javascript to the view file. Here is getuser on the server site, and there is the function. [00:16:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m24s) I have two functions usually one that deals with waiting and then eventually setting up the data into the view. Here is the one making the call. This is how the call structure would usually look in index.php?option=your components name, and the task which must go to the Ajax controller. And then this(getuser) is the task. [00:16:54](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) And here you can stipulate what format you would like the result set returned in. If you want the result set returned raw, which in is sometimes the case, there is if you look here, there is a raw variable. You can just set the raw variable to true. Then it will give you the results set just like that without braces around them, [00:17:23](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m23s) or a call back or anything. You see when you make calls from JavaScript, it usually wants this call back to be added. If you make calls from other JavaScript libraries, you might just want the braces around it. But if you want it raw which also is often the case you just add the variable raw to the URL = true and then end up passing it back to you with this. So that's a little heads up on Ajax function. [00:17:56](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m56s) The format must stay json, that's important.