Updated 008 Advanced Fields (markdown)
parent
26604992ed
commit
d90cd88271
@ -67,16 +67,21 @@ Now to add methods [00:25:09](https://www.youtube.com/watch?v=VpzYbifqv0M&list=P
|
||||
|
||||
There is a whole bunch of custom methods that we ship with all components that are developed. So if you were to open like I have said, 'sermon distributors', [00:27:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m40s) 'helper class', you will see that these helper classes are all showing up , getactions, shortenstring, mergearray. [00:28:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m00s)If you may have a better way of doing this please go on the forums at Github and bring that to my attention. I know I recently tried to improve on this checkstring by doing that(adding {}). So I could actually dump this part(&& strlen($string)>) and save on [00:28:22](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m22s) the query. But for some strange reason this started causing problems all over and strings that were strings were being returned as not being strings. But what I can tell you is that I [00:28:41](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m41s) went back to the old school way of doing it. Which is this way(taking out the {}). I don't know if there might be an easier way. Obviously we first want to ensure that this value($string) is set. If then it is a string, then it actually has a length. Something can be a string and yet does not have a length. [00:29:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m04s)
|
||||
|
||||
Back to the UI. That is where I get these values. (See video)[00:29:29](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m29s) where it says 'getDropboxlinks'. We see that it has this thing '$return' which is set to false. That means if I only was to say, that it should return the manual values, then it will only return the value manual links. But since I've set it [00:29:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m52s) to 2, it will return all of those links and not just one of them, because you can target that it should return one specific sermons link. This method is quite dynamic. That is all I am calling in this advanced [00:30:15](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m15s) field type which is called 'custom field' and it gives me an array of all the links which I have just loaded like I have explained. It is quite an advanced implementation of this custom fields. [00:30:37](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m37s) With that list concept you can almost do anything, you can even grab a bunch of website names from somewhere. You can put any PHP in there and build a list which can be used to save to the database. < Editted
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Back to the UI. That is where I get these values. (See video)[00:29:29](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m29s) where it says 'getDropboxlinks'. We see that it has this thing '$return' which is set to false. That means if I only was to say, that it should return the manual values, then it will only return the value manual links. But since I've set it [00:29:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m52s) to 2, it will return all of those links and not just one of them, because you can target that it should return one specific sermons link. This method is quite dynamic. That is all I am calling in this advanced [00:30:15](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m15s) field type which is called 'custom field' and it gives me an array of all the links which I have just loaded like I have explained. It is quite an advanced implementation of this custom fields. [00:30:37](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m37s) With that list concept you can almost do anything, you can even grab a bunch of website names from somewhere. You can put any PHP in there and build a list which can be used to save to the database.
|
||||
|
||||
**Custom User**
|
||||
|
||||
There's also one called custom user. The custom user at the moment doesn't look like I have any [00:31:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h31m08s) in the demo data for you. I just click on new and then select custom user. You'd see that the custom user basically, 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. 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 our Global, remember we talked about that previously. The options button, if you click on options, [00:32:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h32m07s) it opens a place which you 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 when there(###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) I want to return a specific group. This part helps you set any users you want to exclude. This specific feature here, 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.
|
||||
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 <
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
, 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.
|
||||
|
||||
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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user