Updated 024 How to integrate the Create User Helper Method in your Components (markdown)
parent
6cfae19607
commit
05c3d29901
@ -5,12 +5,7 @@ What is the User Creation function? [00:00:18](https://www.youtube.com/watch?v=c
|
|||||||
|
|
||||||
### Helper Class
|
### Helper Class
|
||||||
|
|
||||||
If the repository is opened you will find Joomla Install, go to administrator. There is a Helper class for the front end of every component as well as for the back end. Looking in a back end, in component there is 'com_expertdatabase'. and under it 'expertdatabase.php'. [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) Go to Helpers, that file(See video), is the Helper class. If it is opened the abstract 'expertdatabaseHelper' may be seen. That Helper class gets included into the component on every page. If the main back end file with that one 'expertdatabase' is opened, which get loaded by Joomla first. It includes that Helper file in every page. [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) It means that everything in that class is available everywhere in the component. Returning to the interface, Component Builder Dashboard, and then go to components and to 'expertdatabase'. There can Library & Helpers be seen . The switch 'add create user helper method', is in the 'yes' position. [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s) That is the switch that should be used, by which Component Builder is commanded that the Helper class that creates Users should be added to the Helper class of the front and back end of the component.
|
If the repository is opened you will find Joomla Install, go to administrator. There is a Helper class for the front end of every component as well as for the back end. Looking in a back end, in component there is 'com_expertdatabase'. and under it 'expertdatabase.php'. [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) Go to Helpers, that file(See video), is the Helper class. If it is opened the abstract 'expertdatabaseHelper' may be seen. That Helper class gets included into the component on every page. If the main back end file with that one 'expertdatabase' is opened, which get loaded by Joomla first. It includes that Helper file in every page. [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) It means that everything in that class is available everywhere in the component. Returning to the interface, Component Builder Dashboard, and then go to components and to 'expertdatabase'. There can Library & Helpers be seen . The switch 'add create user helper method', is in the 'yes' position. [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s) That is the switch that should be used, by which Component Builder is commanded that the Helper class that creates Users should be added to the Helper class of the front and back end of the component. [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s) If this area is closed and you return to the code and a simple search for User is done, quite a few users can be seen as well as 'Create User'.
|
||||||
|
|
||||||
I'm going to close out here. I am going to go back to the code. Then I am going to do a simple . [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s)
|
|
||||||
|
|
||||||
If this area is closed and you return to the code and a simple search for user is done, quite a few users can be seen as well as 'Create User'.
|
|
||||||
|
|
||||||
|
|
||||||
### Create User
|
### Create User
|
||||||
|
|
||||||
@ -27,22 +22,23 @@ If this closed, open a 'New client'. The same values can be seen. [00:08:44](htt
|
|||||||
|
|
||||||
### Make Use Of The Ajax Concept
|
### Make Use Of The Ajax Concept
|
||||||
|
|
||||||
|
|
||||||
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)
|
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.
|
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 an 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.
|
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 an 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 a way that it gets values that has been posted and validates if those values are actually there. The values are then transfered to the model. [00:11:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m05s) That is looking at it from a code perspective. Various methods are displayed in the model and 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 is verified. Here is the 'createUser' class. [00:11:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m31s) First check whether this user, (it is custom script, Component Builder does not write this) so then in returning to the user interface(Editing the Admin view) and scroll down to 'Create user fields, then there is 'Create user'. What has been written here, gets placed into the model. [00:12:07](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m07s) That is the Ajax method. In the Ajax input specific tasks are notated, the task name, and specific variables, and again the method name. Method Names may be different from the Task Names. Select what should be validated(In the 'Select a Filter' area), whether it should be a integer, float etc. and if there's no value(In the 'Default' area), get the default value. This is where the controllers information is set up. [00:12:39](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s) Here may the custom script be done.<<<<<<<<<<<<<<<<<<
|
It uses the Joomla's default filtering method in a way that it gets values that has been posted and validates if those values are actually there. The values are then transfered to the model. [00:11:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m05s) That is looking at it from a code perspective. Various methods are displayed in the model and 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 is verified. Here is the 'createUser' class. [00:11:31](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m31s) First check whether this user, (it is custom script, Component Builder does not write this) so then in returning to the user interface(Editing the Admin view) and scroll down to 'Create user fields, then there is 'Create user'. What has been written here, gets placed into the model. [00:12:07](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m07s) That is the Ajax method. In the Ajax input specific tasks are notated, the task name, and specific variables, and again the method name. Method Names may be different from the Task Names. Select what should be validated(In the 'Select a Filter' area), whether it should be a integer, float etc. and if there's no value(In the 'Default' area), get the default value. This is where the controllers information is set up. [00:12:39](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m39s) Here may the custom script be done. Create user gets data and determines from what view it is, then validates whether 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 is transferred and checks whether it's an array and does some other checks.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
### Global Helper Class
|
### Global Helper Class
|
||||||
|
|
||||||
So you can see I'm still using that [00:13:17](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m17s) global helper class and methods. Here are number of custom methods obviously that is available in that class. Go through it. We just add it in there as freebies and you don't want to always see the need of them but I'm using them often. Even if you have improvements on those methods, please make a pull request and we'll make those changes. 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.
|
[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.<<<<<<<<<<<<<<<
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user