Updated 008 Advanced Fields (markdown)
parent
d90cd88271
commit
66d15ce289
@ -71,19 +71,22 @@ Back to the UI. That is where I get these values. (See video)[00:29:29](https://
|
|||||||
|
|
||||||
**Custom User**
|
**Custom User**
|
||||||
|
|
||||||
There's also a function called custom user. [00:31:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m08s) In the custom user, you don't need to set or change anything from [00:31:25](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m25s) here to there(See video). All those should actually just work. The only part that you want to consider removing, would be the PHP, this part here(see video). Basically what this part does, it limits the user list [00:31:47](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m47s) to only a certain group. That means again you need to set up a global value in your component field. In the Global, as mentioned previously, if you click on 'options', [00:32:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m07s) it will opens a place which you need to set 'global'. These are all global values. This is a area for global values. You can get hold of those global values through the component helper 'getparams' with a component name and get (###text###) you would place the field name. [00:32:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m28s) That's how you can get a value from your global settings. And basically I'm getting a specific groups value and placing it in here(groups). And then I am returning that group. That is all this part(see video) is doing. Those two sections are actually independent. So this one is what helps you set [00:32:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m52s) to return a specific group. This part helps you set any users you want to exclude. This specific feature here <
|
There's also a function called custom user. [00:31:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m08s) In the custom user, you don't need to set or change anything from [00:31:25](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m25s) here to there(See video). All those should actually just work. The only part that you want to consider removing, would be the PHP, this part here(see video). Basically what this part does, it limits the user list [00:31:47](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m47s) to only a certain group. That means again you need to set up a global value in your component field. In the Global, as mentioned previously, if you click on 'options', [00:32:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m07s) it will opens a place which you need to set 'global'. These are all global values. This is a area for global values. You can get hold of those global values through the component helper 'getparams' with a component name and get (###text###) you would place the field name. [00:32:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m28s) That's how you can get a value from your global settings. And basically I'm getting a specific groups value and placing it in here(groups). And then I am returning that group. That is all this part(see video) is doing. Those two sections are actually independent. So this one is what helps you set [00:32:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m52s) to return a specific group.
|
||||||
|
|
||||||
|
**The Exclude Feature**
|
||||||
|
|
||||||
|
This part helps you set any users you want to exclude. This specific feature here(See video) ensures that only one record per user is set. Let's say a user has already been added to a previous record, then that user should not show up again. [00:33:18](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m18s) It should be removed from the list. This is what this PHP is doing. It's simply looking to this current view and checking if there is users and getting their ID's and setting them up in their unique manner and then returns them. [00:33:36](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m36s) If you are building something which are supposed to have student details, for example, you don't want a student to have more than one entry in that table, you want every student to just have one. [00:33:58](https://www.youtube.com/watch?v=VpzYbifHTMLqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m58s) So if a student is already selected, you do not want them to be selected again, that's what this exclude feature does.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Now to show that to you in the code. Let's go to another project that I am working on called learning manager and models. And they have a field called studentusers and studentuser. [00:34:27](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m27s) There are two kinds of ways to do this. One is to not allow more than one user to have an entry and the other is saying exclude users that already have been used. So that means if a user have been selected, [00:34:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m52s) the other one returns null, which means it will always show all users. The way to have it set to null would be simply to remove that part(selected on video) of the code. Then Component Builder will automatically set this 'return null' value to null. When it get to the group part the principle is the same. [00:35:19](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m19s) If you don't want it to just show a specific group, you can actually set it to null. Like that(return null) and Component Builder will do that. All you need to do is simply remove that part of the code and it will target a specific group [00:35:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m48s) or to remove specific users. For example: If you want to remove users that belongs to other table or other structure, then all the PHP that you need to write, you can place it on the 'type_phpx'. [00:36:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m11s) So you could do that 'type_phpx_1='. and all your PHP can be placed in here for excluding. [00:36:33](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m33s) This 'type_php_1' will be used for the groups. It actually says Getexcluded method and PHP for the getgroup method and in the code which is stored under 'fields'and 'models' can be seen what it does. You can do things and then come and look [00:36:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m59s) what Component Builder build. You can go to the view like we have here(See video) and see how it actually work. Is the preachers showing up? You can use firebug and you can look,<<
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
, ensures that only one record per user is set. Let's say a user has already been added to a previous record, then that user should not show up again. [00:33:18](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m18s) It should be removed from the list. This is what this PHP is doing. It's simply looking to this current view and checking if there is users and getting their ID's. And then setting them up in the correct manner. They are unique and then returns them. [00:33:36](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m36s) Those are the users that already have. If you are building something which are supposed to have student details, for example, you don't want a student to have more than one entry in that table, you want every student to just have one in. [00:33:58](https://www.youtube.com/watch?v=VpzYbifHTMLqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m58s) And so if a student already is selected, you wouldn't want them to be selected again, that's what this exclude feature does.
|
that one is [00:37:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m24s) of the index. You will use that(preacher). Here is a select list. And here you have the values. So that's the IDs and that is the actual name of the speaker. The ID and the name. That is how it should display the data. Component Builder sets up the XML structure that Joomla uses [00:37:53](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m53s) to build this. Joomla is building this whole structure for you. So even this nice button and everything is Joomla's handiwork. It is doing that for you and this is all done through these XML [00:38:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s) input values that you are adding here. So you would change the type to, you might say, staff members.
|
||||||
|
|
||||||
Now to show that to you in the code. Let's go to another project that I am working on called learning manager and models. And they have a field called studentusers and studentuser. [00:34:27](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m27s) There are two kinds of ways to do this. One is to not allow more than one user to have an entry. And the one is saying exclude users that already have been used. So that means if a user have been selected that whole thing that I've just explained. [00:34:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m52s) The other one returns null. Which means it will always show all users. And the way to have it set this to null would be simply to remove that part(selected on video) of the code. Then it will automatically set this(return null) value to null, component builder will do that. When I gets about the group part it's the same principle. [00:35:19](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m19s) If you don't want it to just show a specific group, you can actually set it to null. Like that(return null) and component builder will do that. All you need to do is simply remove what is part of the code. And it will actually do that. And that is to target a specific group. [00:35:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m48s) And also to target or to remove specific users. Let's say that you want to remove users that belongs to other table or other structure, then all that PHP that you need to write, you can place it on the type_phpx. [00:36:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m11s) So you could do that type_phpx1=. All your PHP can be placed in here for excluding. And for the group, it's simply, not directly one, it must have an underscore(_). [00:36:33](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m33s) You can just take that one. And this one will be used for the groups. It says it there Getexcluded method. PHP for the getgroup method. And in the code which is stored under fields, models. You will see what it will do. You can do things and then come and look [00:36:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m59s) what did component builder build. How does it look then. You can go to the view like we have here. And see does it's actually work? Is the preachers showing up? And then you can use firebug like that, and you can look, that one is [00:37:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m24s) of the index. You will use that(preacher). Here is a select list. And here you have the values. So that's the IDs and that is the actual name of the speaker. The ID and the name. That is how it should display the data. Component Builder sets up the XML structure that Joomla uses [00:37:53](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m53s) to build this. Joomla is building this whole structure for you. So even this nice button and everything is Joomla's handiwork. It is doing that for you and this is all done through these XML [00:38:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s) input values that you are adding here. So you would change the type to, you might say, staff members.
|
|
||||||
|
|
||||||
There is something to remember here. The type names may not have underscores or any spaces in them. Anything that is not translatable usually needs to be [00:38:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m35s) not have any spaces. So you can't do this(add spaces). It will not work. So you must remove the underscore. You can do that(Uppercase M) but that will be made lowercase anyway. [00:38:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m57s) So you could just do that(lowercase m) instead. It will work because that is used not only in the file database but it's also used in the name convention and everywhere this file type is. So as you can see in here(code) that file type is called studentusers. And even the file is called that(studentusers). [00:39:21](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m21s) And here it is called studentuser, and here it is called studentuser. And this one(jformfieldstudentusers) is with the s. That one(studentusers) with a s. In the file is also with a s. So you can see that specific type name is used everywhere. And you cannot have underscores in this class name. Neither in this type name. [00:39:46](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m46s) Maybe you can but so far my experience is that it doesn't work if you do have it. For some reason it doesn't work. That's just a heads up on naming of this type. So you can update these fields. They are mostly fields that are [00:40:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m07s) related to all the other fields. But this one specifically says extends user. It shows you how it's going to extend it. So if you removed all the PHP then this field as it is now, will show all users everytime. Let me just [00:40:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m28s) close out here. That is looking at the advanced field type called custom user.
|
There is something to remember here. The type names may not have underscores or any spaces in them. Anything that is not translatable usually needs to be [00:38:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m35s) not have any spaces. So you can't do this(add spaces). It will not work. So you must remove the underscore. You can do that(Uppercase M) but that will be made lowercase anyway. [00:38:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m57s) So you could just do that(lowercase m) instead. It will work because that is used not only in the file database but it's also used in the name convention and everywhere this file type is. So as you can see in here(code) that file type is called studentusers. And even the file is called that(studentusers). [00:39:21](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m21s) And here it is called studentuser, and here it is called studentuser. And this one(jformfieldstudentusers) is with the s. That one(studentusers) with a s. In the file is also with a s. So you can see that specific type name is used everywhere. And you cannot have underscores in this class name. Neither in this type name. [00:39:46](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m46s) Maybe you can but so far my experience is that it doesn't work if you do have it. For some reason it doesn't work. That's just a heads up on naming of this type. So you can update these fields. They are mostly fields that are [00:40:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m07s) related to all the other fields. But this one specifically says extends user. It shows you how it's going to extend it. So if you removed all the PHP then this field as it is now, will show all users everytime. Let me just [00:40:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m28s) close out here. That is looking at the advanced field type called custom user.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user