Updated 008 Advanced Fields (markdown)

Amigo 2019-08-15 17:33:07 +02:00
parent 573e3755df
commit 3e6fe8a0f0

@ -9,17 +9,17 @@ There are a few advanced field types. The most advanced is one called custom fie
[00:00:38](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m38s)
Let us look at two of these. One is the local file list, the other one is 'sermon'. We'll look at the local first. You will see that the whole 'XML field definition' column is PHP. I'm creating a view that is taking information from the global settings of your component so that there need to be a field with a name 'localfolder' in your global settings. When we get to component we'll look at setting up global settings. If it doesn't have a setting it falls back onto the image which is in the 'JPATH ROOT'. For your component this will be replaced with your component name. It places it into local folder. [00:01:36](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m36s)
Let us look at two of these. One is the local file list, the other one is 'sermon'. We'll look at the local first. You will see that the whole 'XML field definition' column is PHP. I'm creating a view that is taking information from the global settings of your component so that there needs to be a field with a name 'localfolder' in your global settings. When we get to the components we'll look at setting up global settings. If it doesn't have a setting it falls back onto the image which is in the 'JPATH ROOT'. For your component, this will be replaced with your component name. It places it into a local folder. [00:01:36](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m36s)
Now I start the options array, which you are going to return. Select 'Please add files'. If there aren't files it will say 'Please add files' too, and give the local folder name. If there are files, we are going to update them at 'JFolder'. First we bring in the file system classes from Joomla, then we check whether that folder exists. If it doesn't exist we create it in the field type. Once it's created and it exists, it doesn't go in there; it grabs all the files from the folder and place it into files and starts up an array where it loops the files and places it into options. [00:02:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m40s) By doing that we are adding the file names to our options array. Returning the options array. You can add your own custom PHP scripting when you extend a list field. We are extending a list field. It is going to be a drop down list of all the files in that specific folder; either images or the folder that was set globally in local folder.
Now I start the options array, which you are going to return. Select 'Please add files'. If there aren't files it will say 'Please add files' too, and give the local folder name. If there are files, we are going to update them at 'JFolder'. First, we bring in the file system classes from Joomla, then we check whether that folder exists. If it doesn't exist we create it in the field type. Once it's created and it exists, it doesn't go in there; it grabs all the files from the folder and place it into files and starts up an array where it loops the files and places it into options. [00:02:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m40s) By doing that we are adding the file names to our options array. Returning the options array. You can add your own custom PHP scripting when you extend a list field. We are extending a list field. It is going to be a drop-down list of all the files in that specific folder; either images or the folder that was set globally in the local folder.
There is a field type called 'file list'. I didn't use file list because file list has a static directory to where you need to add the files to view them. [00:03:44](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m44s) We want it to rename the folder for the files, for the media, etc. then have it update itself automatically. So we created a custom field where we extended the list type. We chose a custom field, and then extended the list type. (We don't want it to add 'new button' because it won't work.) We are allowing them to select multiple. Since we are using multiple, we need to make sure that we are storing it as a 'JSON'. That is when you have 'multiple' or 'arrays', or any kind of arrays in a value that needs to be stored as a 'JSON'. [00:04:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m48s) The component builder itself will check if the multiple selection is true and automatically store it in a 'JSON' object even if you forgot to select 'JSON'.
There is a field type called 'file list'. I didn't use file list because file list has a static directory to where you need to add the files to view them. [00:03:44](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m44s) We want it to rename the folder for the files, for the media, etc. then have it update itself automatically. So we created a custom field where we extended the list type. We chose a custom field, and then extended the list type. (We don't want it to add 'new button' because it won't work.) We are allowing them to select multiple. Since we are using multiple, we need to make sure that we are storing it as a 'JSON'. That is when you have 'multiple' or 'arrays', or any kind of arrays in a value that needs to be stored as a 'JSON'. [00:04:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m48s) The component builder itself will check if the multiple selections are true and automatically store it in a 'JSON' object even if you forgot to select 'JSON'.
### How to Create a Sermon Preacher Custom Field
[00:05:32](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m32s)
It is a preacher custom field. It will show a list of preachers, but will display the preachers that are set up in the preacher list view. Open that 'Sermon Preacher.' The convention is that you should call the type, preachers, that is the list view name. You should use the same as the editing name which is preacher without the 's'. If you go back to your admin views you would use this name as the name of the field, but you have to use that name as the type because you are now creating a custom type. The logic behind it is that while it shows a list of preachers, you might have selected just one preacher.
It is a preacher custom field. It will show a list of preachers but will display the preachers that are set up in the preacher list view. Open that 'Sermon Preacher.' The convention is that you should call the type, preachers, that is the list view name. You should use the same as the editing name which is 'preacher' without the 's'. If you go back to your admin views you would use this name as the name of the field, but you have to use that name as the type because you are now creating a custom type. The logic behind it is that while it shows a list of preachers, you might have selected just one preacher.
You can use any label you like, whatever is descriptive enough for your user to understand. There is a place for adding a description. In 'XLM field definition' we set multiple to false. They should be able to only select one preacher at a time. At 'Default 0' all are left to their default values. [00:06:56](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m56s)
@ -27,25 +27,25 @@ You can use any label you like, whatever is descriptive enough for your user to
[00:07:02](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m02s)
'Extending list' is the most common custom field that we have. If you want to receive a list of custom fields that is available, you can go up here to 'extend' and see the list, radio, and check boxes that are available. User is also a user option to extend users. If you want to see what is available, look at that name 'Jformfield' and go to component builder. Go to the back end of component builder. (See video.) Go to compiler, then to Joomla 3, which is the current version we are targeting. Search for that Jform. [00:08:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) Those available to extend are user, Jform field, JForm field user, Jform field radio, Jform field list, and Jform field checkboxes. This means that if there is a form field you want to extend that doesn't exist in our advanced seminar, you will be shown how to add your own form fields here. There would be two places you need to change. One of them would be adding the field and update it accordingl; the other one would be adding it in the code at some places and in a Json file called settings there. These are some of the things we will deal with in the advanced adaptation of component builder. [00:09:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m04s)
'Extending list' is the most common custom field that we have. If you want to receive a list of custom fields that is available, you can go up here to 'extend' and see the list, radio, and checkboxes that are available. User is also a user option to extend users. If you want to see what is available, look at that name 'Jformfield' and go to Component Builder. Go to the back end of Component Builder. (See video.) Go to the compiler, then to Joomla 3, which is the current version we are targeting. Search for that Jform. [00:08:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m00s) Those available to extend are user, Jform field, JForm field user, Jform field radio, Jform field list, and Jform field checkboxes. This means that if there is a form field you want to extend that doesn't exist in our advanced seminar, you will be shown how to add your own form fields here. There would be two places you need to change. One of them would be adding the field and update it accordingly; the other one would be adding it in the code at some places and in a JSON file called settings there. These are some of the things we will deal with in the advanced adaptation of component builder. [00:09:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m04s)
### Extending List in Custom Field
[00:09:16](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m16s)
Getting back to extending a list field: you simply add list. There are a few conventions. One of them is that if you are going to be targeting 'Preachers' for example, you will be using the preacher table as the table being targeted. The question to ask is where the data going to be found. This table needs to be added. (See video.) The reason why we have this 'component' here is because it's a placeholder which component builder will replace with the component's code name once it's built. [00:10:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m08s) We added this feature because sometimes we want to rename components. If you had statically added the actual component name there, you have to update that name in every field and view.
Getting back to extending a list field: you simply add the list. There are a few conventions. One of them is that if you are going to be targeting 'Preachers' for example, you will be using the preacher table as the table being targeted. The question to ask is where the data going to be found. This table needs to be added. (See video.) The reason why we have this 'component' here is that it's a placeholder which component builder will replace with the component's code name once it's built. [00:10:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m08s) We added this feature because sometimes we want to rename components. If you had statically added the actual component name there, you have to update that name in every field and view.
To explain what the system is doing, go to components, open 'Sermon Distributor,' take the name in code, like that 'sermondistributor', copy, and you'll see that it is a lowercase 'c.' If it had been an uppercase l it would mean that you'd have to place the component's name with an uppercase as well. [00:11:12](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m12s) The system is replacing these place holders with the actual component name on the fly. Using the placeholders saves you time in the long run from making changes everywhere if you make a change to a component's name. Which is quite normal to do. Often you start with the component and think of calling it something and later realize that the name is been used in the Joomla repository, and you need to choose another name. To do that is going to affect the whole component, so we added this placeholder structure which should make the data easier.
In all the custom coding that you're adding where you need to use the components name, you can use the tag format of replacement. [00:12:16](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m16s) In some areas you would need to use brackets. Most of the time it works either way. The best way to ensure that it works is to try it with a hashtag first; if it didn't replace it in the code, the angle brackets need to be used. In this case we are using these ### characters. Again, the view is the single variable of the view. If we close and go to the view which would be preacher, all lowercase is what you would be adding here. Make sure that it's always lowercase. [00:13:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m20s)
In all the custom coding that you're adding where you need to use the components name, you can use the tag format of replacement. [00:12:16](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m16s) In some areas you would need to use brackets. Most of the time it works either way. The best way to ensure that it works is to try it with a hashtag first; if it didn't replace it in the code, the angle brackets need to be used. In this case, we are using these ### characters. Again, the view is the single variable of the view. If we close and go to the view which would be preacher, all lowercase is what you would be adding here. Make sure that it's always lowercase. [00:13:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m20s)
The list view (or the views plural) would be the add value there. All lowercase too. The value field is the field that the user will see. It is visible in the UI user interface. The key field is the value that will be stored in the database. This field relate to this table (#-###component###-preacher). Inside this table, which field do you want the user to see? The name of the preacher. Inside this table, which field would you want to store in the other database? We are going to store it wherever the field is being used. That would be the ID and the column name in that data base of that view where this field will be used. [00:14:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m24s) It will be called preacher. To show that in the database itself. Open it. (See video.) Go to sermons, click 'new,' and you will see a place for preacher. If you were to look with firebug at it, you'd see that it is the name is preacher. (Remember we spoke about this Jform_ as the ID.) It's simply the preacher field which is being stored directly in the database in the preacher column of the table. [00:15:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) It's stored as INT 11 and we say that it is a key. We can target it. If we look at indexes, we'll see that it had added it as a key.
The list view (or the views plural) would be the added value there. All lowercase too. The value field is the field that the user will see. It is visible in the UI user interface. The key field is the value that will be stored in the database. This field relate to this table (#-###component###-preacher). Inside this table, which field do you want the user to see? The name of the preacher. Inside this table, which field would you want to store in the other database? We are going to store it wherever the field is being used. That would be the ID and the column name in that database of that view where this field will be used. [00:14:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m24s) It will be called 'preacher.' To show that in the database itself. Open it. (See video.) Go to sermons, click 'new,' and you will see a place for 'preacher.' If you were to look with firebug at it, you'd see that it is the name is 'preacher.' (Remember we spoke about this Jform_ as the ID.) It's simply the preacher field which is being stored directly in the database in the preacher column of the table. [00:15:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m28s) It's stored as INT 11 and we say that it is a key. We can target it. If we look at indexes, we'll see that it had added it as a key.
### Custom PHP layout in Field Definition
[00:15:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m59s)
All of that is done in the database structure and in this area. (See video.) Here you can add your own custom PHP. I'm using 19, 18, 17, etc so that it's creating line breaks and spacing and tabs for me dynamically. I could have placed them all under PHP one, without these quotation marks. [00:16:32](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m32s) We wrap around them like we did with the file folder list view example we did previously.
All of that is done in the database structure and in this area. (See video.) Here you can add your own custom PHP. I'm using 19, 18, 17, etc so that it's creating line breaks and spacing and tabs for me dynamically. I could have placed them all under PHP one, without these quotation marks. [00:16:32](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m32s) We wrap around them as we did with the file folder list view example we did previously.
(Just a note: inside of this code, you can't use quotation marks; you need to use single quotes, even if you try to do an escape. It will not behave as you might expect.)
@ -57,7 +57,7 @@ These place holders reflect back to these 'key_field_id' values. (See video.) Ba
* Example (See Video) [00:18:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m07s)
To show you how it looks when it is being built. Open jformfieldlist. That is what it starts with, replacing this place holder with your code. It replaces all these features up here as well. [00:18:30](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m30s) Everywhere you see '###component###', it will be updated through component builder. Everything here will be replaced with your licensing tags. Let's look at the finished product. Sermon is placed on the module field and there is 'preachers'. [00:18:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m57s) If you open it you'd see that it added preacher there, and the input added. If you trip that switch, like we have explained, to show the line numbers in your component. It shows you in what file. [00:19:15](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m15s) These files are found if you go to component builder, helpers compiler. These are the files that are being used to compile your component.
To show you how it looks when it is being built. Open jformfieldlist. That is what it starts with, replacing this place holder with your code. It replaces all these features up here as well. [00:18:30](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m30s) Everywhere you see '###component###', it will be updated through component builder. Everything here will be replaced with your licensing tags. Let's look at the finished product. 'Sermon' is placed on the module field and there is 'preachers'. [00:18:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m57s) If you open it you'd see that it added preacher there, and the input added. If you trip that switch, like we have explained, to show the line numbers in your component. It shows you in what file. [00:19:15](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m15s) These files are found if you go to Component Builder, helpers compiler. These are the files that are being used to compile your component.
### Generate a New Button
@ -65,7 +65,7 @@ To show you how it looks when it is being built. Open jformfieldlist. That is wh
We are trying to build a component, not as yet to extend component builder itself. Here you can see where in the code it is building, compiling, and putting this together. [00:19:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m59s) This is used for the button. (See video.) This is to generate a new button. When you click on new, this is the button. This area is generating the button. This controls whether the button should show up or not. [00:20:21](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m21s) If it is to be set at all, this is what generates the button. We said that the 'get options' will show the name and 'ID'. Going back to our structure here, we dynamically replace these (###ID###,###name###) with 'view preachers'. The reason for this is that it's done a few times. [00:20:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m48s) We'll say that you only need to update these values and it would get updated all over in the bottom of the code. It makes it easier to change your custom fields. A field called preacher name was built. Which again used 'preacher_name' as an object value. [00:21:17](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m17s) Because it retrieves the object from the database and it seems as if the object exists, it reiterates and builds up option list which is returned to use in the dropdown. It dynamically generates your list. So component builder through this infrastructure compiles all of the code for you and puts it in the right file in the right place. [00:21:37](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m37s)
Once you have built a component and know where you have made those changes in component builder you can look at the files if you know how to build a Joomla website. I used the same conventions as decor in regards to implementation of the files. [00:22:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m07s)
Once you have built a component and know where you have made those changes in component builder you can look at the files if you know how to build a Joomla website. I used the same conventions as decor in regards to the implementation of the files. [00:22:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m07s)
### Dropbox Custom List Example
@ -77,13 +77,13 @@ We will now look at Dropbox manual file list, which is more advanced. We are dea
[00:23:32](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m32s)
This part means that you can add a helper static method call in your custom field types. These two symbols mean that it is a static method being called from a class. If you know the Joomla API and how to work with builder component, you will know that you can add a component helper class to any component. [00:24:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m07s) If I go to sermon distributor, the component helper class is always located in the helper folder of the admin as well as the site view. The admin is in the back end in which is administrative components. [00:24:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m28s) There you'd see the component and its helper folder. In the front end you have the same convention, component, and sermon distributor. There is the helper structure. Here is some of the script of sermon distributor structures through its helper structure. There is the helper file for the front. Here is helper file for the back. (See video.) [00:24:49](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m49s)
This part means that you can add a helper static method call in your custom field types. These two symbols mean that it is a static method being called from a class. If you know the Joomla API and how to work with builder component, you will know that you can add a component helper class to any component. [00:24:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m07s) If I go to sermon distributor, the component helper class is always located in the helper folder of the admin as well as the site view. The admin is in the back end in which is administrative components. [00:24:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m28s) There you'd see the component and its helper folder. In the front end, you have the same convention, component, and sermon distributor. There is a helper structure. Here is some of the script of sermon distributor structures through its helper structure. There is the helper file for the front. Here is helper file for the back. (See video.) [00:24:49](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m49s)
### Adding Methods to the Helper Files
[00:25:10](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m10s)
If you want to know what the custom helpers are that we ship with all components, you can open component builder. Go to the compiler and Joomla 3 then look for the helper file in the site helper file. [00:25:30](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m30s) If you open it you'll see many helper methods. With a lot of place holders we customize for each component that targets that component. You'd see a Json to string method here to 'getvars'. (See video.) There's a 'getvar' singular. This is getting one variable from the database so you don't need to rewrite the whole string to get one variable. [00:25:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m55s) You can look at how this works and use it to get a variable from the database. We also have 'ispublished' to check if a specific object is published. [00:26:14](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m14s) I wrote these functions. (See video.) [00:26:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m40s) If you do savestring we change every number in the string to text, so that you can be sure that whatever you get back from savestring doesn't have numbers in it. [00:26:58](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m58s) In this way we are insuring that it is always text. It's is quite necessary, especially if you don't know if the first character might be a number.
If you want to know what the custom helpers are that we ship with all components, you can open component builder. Go to the compiler and Joomla 3 then look for the helper file in the site helper file. [00:25:30](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m30s) If you open it you'll see many helper methods. With a lot of place holders, we customize for each component that targets that component. You'd see a Json to string method here to 'getvars'. (See video.) There's a 'getvar' singular. This is getting one variable from the database so you don't need to rewrite the whole string to get one variable. [00:25:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m55s) You can look at how this works and use it to get a variable from the database. We also have 'ispublished' to check if a specific object is published. [00:26:14](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m14s) I wrote these functions. (See video.) [00:26:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m40s) If you do save string we change every number in the string to text so that you can be sure that whatever you get back from save string doesn't have numbers in it. [00:26:58](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m58s) In this way we are ensuring that it is always text. It's is quite necessary, especially if you don't know if the first character might be a number.
### Strings
@ -101,15 +101,15 @@ There's also a function called custom user. In the custom user, you don't need t
* The Exclude Feature
This part helps you set any users you want to exclude. This specific feature here ensures that only one record per user is set. (See video.) Let's say a user had 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) The user should be removed from the list. This is what this PHP is doing. It looks to the current view and checks if there are users; it gets their ID's and sets them up in their unique manner, 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)
This part helps you set any users you want to exclude. This specific feature here ensures that only one record per user is set. (See video.) Let's say a user had 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) The user should be removed from the list. This is what this PHP is doing. It looks to the current view and checks if there are users; it gets their ID's and sets them up in their unique manner, then returns them. [00:33:36](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h33m36s) If you are building something which is 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)
Now to show that to you in the code. Let's go to another project that I am working on: 'Learning Manager and Models.' There are fields called studentusers and studentuser. [00:34:27](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m27s) There are two ways to do this. One is not allowing more than one user to have an entry; the other is excluding users that have already been used. That means if a user have been selected, the other one returns null. [00:34:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m52s) In other words, it will always show all users. The way to have it set to null would be to remove this part of the code. (See video.) Then Component Builder will automatically set this 'return null' value to null. When it gets 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 show a specific group, you can set it to null. All you need to do is remove that part of the code and it will target a specific group or to remove specific users. [00:35:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m48s) For example: If you want to remove users that belongs to another table or structure, all the PHP that you need to write can be placed on the 'type_phpx'. [00:36:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m11s) So all your PHP can be placed in here for excluding. (See video.) [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 says Getexcluded method and PHP for the getgroup method and in the code which is stored under 'fields'and 'models' where can be seen what it does. You can do things and then look what Component Builder build. [00:36:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m59s) You can go to any view and see how it works.[00:37:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m24s) You will use that(preacher).
Now to show that to you in the code. Let's go to another project that I am working on: 'Learning Manager and Models.' There are fields called studentusers and studentuser. [00:34:27](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m27s) There are two ways to do this. One is not allowing more than one user to have an entry; the other is excluding users that have already been used. That means if a user has been selected, the other one returns null. [00:34:52](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h34m52s) In other words, it will always show all users. The way to have it set to null would be to remove this part of the code. (See video.) Then Component Builder will automatically set this 'return null' value to null. When it gets 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 show a specific group, you can set it to null. All you need to do is remove that part of the code and it will target a specific group or remove specific users. [00:35:48](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h35m48s) For example: If you want to remove users that belongs to another table or structure, all the PHP that you need to write can be placed on the 'type_phpx'. [00:36:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m11s) So all your PHP can be placed in here for excluding. (See video.) [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 says Getexcluded method and PHP for the getgroup method and in the code which is stored under 'fields' and 'models' where can be seen what it does. You can do things and then look at what Component Builder build. [00:36:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h36m59s) You can go to any view and see how it works. [00:37:24](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m24s) You will use that(preacher).
Here is a select list; here you have the values. That's the IDs and the actual name of the speaker. This is how it should display the data. Component Builder sets up the XML structure that Joomla uses to build this. [00:37:53](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h37m53s) Joomla is building this whole structure for you. It is done through these XML input values that you are adding here. [00:38:08](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m08s)
* No Underscores or Spaces
Something to remember here: the type names may not have underscores or any spaces in them. Anything that isn't translatable usually needs to be without spaces. [00:38:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m35s) You must also remove the underscore. You can use uppercase but it will be become lowercase anyway. [00:38:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m57s) This works because it isn't only used in the file database but also in the name convention and everywhere this file type is. You can see in here that the file type is called studentusers and even the file is called studentusers. [00:39:21](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m21s) Specific type name is used everywhere.
Something to remember here: the type names may not have underscores or any spaces in them. Anything that isn't translatable usually needs to be without spaces. [00:38:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m35s) You must also remove the underscore. You can use uppercase but it will become lowercase anyway. [00:38:57](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h38m57s) This works because it isn't only used in the file database but also in the name convention and everywhere this file type is. You can see in here that the file type is called studentusers and even the file is called studentusers. [00:39:21](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h39m21s) Specific type name is used everywhere.
You can update these fields. Mostly they are fields that are related to all the other fields. [00:40:07](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m07s) This one specifically says extends user. It shows you how it's going to extend it. If you removed all the PHP, the field like this will show all users every time. [00:40:28](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m28s)
@ -117,13 +117,13 @@ You can update these fields. Mostly they are fields that are related to all the
[00:40:38](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m38s)
Repeatable fields aren't that difficult but you need to understand how it's structured. First you need to create the fields that you want to repeat inside repeatable fields. [00:40:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m55s) This is a repeatable field. (See video.) If you know a little XML and worked with repeatable fields, you'd see that the fields are being repeated inside of the repeatable field. [00:41:23](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h41m23s) Repeatable field is a field type that has other fields inside of it.
Repeatable fields aren't that difficult but you need to understand how it's structured. First, you need to create the fields that you want to repeat inside repeatable fields. [00:40:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h40m55s) This is a repeatable field. (See video.) If you know a little XML and worked with repeatable fields, you'd see that the fields are being repeated inside of the repeatable field. [00:41:23](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h41m23s) Repeatable field is a field type that has other fields inside of it.
You don't need to write any of this. It's very simple to structure a repeatable field. [00:41:47](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h41m47s) First you create the fields that you want to repeat. You can't use repeatable fields in repeatable fields, but you can use custom advanced fields in repeatable fields.
* Cause and Risks
Here is a field type called 'cause and risks'. (See video.) If you know Joomla you'd know there is no such field type. That means that this is a custom field. If you were to go to fields, you'd see a field called 'cause and risks'. [00:42:16](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h42m16s) It gets its information from this database table. This is another component that I've done with component builder. [00:42:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h42m35s) It is displaying that data, making some model changes and adding some style to the data.
Here is a field type called 'cause and risks'. (See video.) If you know Joomla you'd know there is no such field type. That means that this is a custom field. If you were to go to fields, you'd see a field called 'cause and risks'. [00:42:16](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h42m16s) It gets its information from this database table. This is another component that I've done with Component Builder. [00:42:35](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h42m35s) It is displaying that data, making some model changes and adding some style to the data.
You're able to add an advance custom field inside of a repeatable field. However, for example, you need to have the field ID and you have to order it according to the order you want it displayed in the line where you do repeatable fields. [00:43:17](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h43m17s) Here you will see that there a number of fields in one row. (See video.) If I click next they all appear again etc. [00:43:43](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h43m43s) That's what repeatable fields is about.
@ -133,16 +133,16 @@ Here I developed this specific pop-up repeatable structure. (See video.) Here is
[00:44:41](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h44m41s)
If we go back to the view, you'd see that it says add. I'm adding an ID in a class to it. A description would appear if we were to hover over it. It has a little setup field for this view which is the description. [00:44:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h44m59s) The label is fields; the icon is what is shown in the button, a list. [00:45:17](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h45m17s) All those custom Joomla icons can be used. To know these icons you should go to URL Docs.joomla.org/J3.x:Joomla_Standard_Icomoon_ fonts. You'll get to Available Icomoon Icons. [00:45:41](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h45m41s)
If we go back to the view, you'd see that it says 'add.' I'm adding an ID in a class to it. A description would appear if we were to hover over it. It has a little setup field for this view which is the description. [00:44:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h44m59s) The label is fields; the icon is what is shown in the button, a list. [00:45:17](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h45m17s) All those custom Joomla icons can be used. To know these icons you should go to URL Docs.joomla.org/J3.x:Joomla_Standard_Icomoon_ fonts. You'll get to Available Icomoon Icons. [00:45:41](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h45m41s)
These are all the available icons. You use contract-2 and checkmark-circle. If I wanted to checkmark-circle, I'd copy checkmark-circle and change the icon to checkmark-circle. [00:46:02](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h46m02s) That's how you change the icon.
These are simply the ID's of the fields I want inside of the repeatable field. [00:46:22](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h46m22s) You'd find the IDs next to the fields on the right if you close repeatable fields. You'd create the fields that you want to use in the repeatable field and get a list of those ID's jotted down somewhere. [00:46:51](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h46m51s) Add them in the order that you want them to be added. Inside of your repeatable field paste it in the fields area with a comma separating them. Then component builder will dynamically construct the whole structure for you and add it to your component. [00:47:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h47m11s)
These are simply the IDs of the fields I want inside of the repeatable field. [00:46:22](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h46m22s) You'd find the IDs next to the fields on the right if you close repeatable fields. You'd create the fields that you want to use in the repeatable field and get a list of those ID's jotted down somewhere. [00:46:51](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h46m51s) Add them in the order that you want them to be added. Inside of your repeatable field paste it in the area of the fields with a comma separating them. Then component builder will dynamically construct the whole structure for you and add it to your component. [00:47:11](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h47m11s)
### Radio Buttons: A Note
[00:47:39](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h47m39s)
A note: you need to remove the class of the radio buttons you use in the repeatable fields. It can't be a button; it must be a dot. Unfortunately they don't make it possible to load the button. What's the difference? [00:47:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h47m59s) CSS YES/NO is the button version of a radio button. Searchable Yes/No is the dot version of the radio button. It doesn't look like a button. [00:48:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h48m20s) What makes it a button? It is the class that is being added to the field. You need to remove the class values from your radio button if it's going to be used in the repeatable field. [00:48:38](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h48m38s) If you forgot to do that and compile your component you'll see that the radio button is not working if you look at the repeatable field, but that it messed up.
A note: you need to remove the class of the radio buttons you use in the repeatable fields. It can't be a button; it must be a dot. Unfortunately, they don't make it possible to load the button. What's the difference? [00:47:59](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h47m59s) CSS YES/NO is the button version of a radio button. Searchable Yes/No is the dot version of the radio button. It doesn't look like a button. [00:48:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h48m20s) What makes it a button? It is the class that is being added to the field. You need to remove the class values from your radio button if it's going to be used in the repeatable field. [00:48:38](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h48m38s) If you forgot to do that and compile your component you'll see that the radio button is not working if you look at the repeatable field, but that it messed up.
That was looking at advanced fields called custom fields, custom user fields, as well as repeatable fields. [00:49:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h49m04s) These were the advanced field types that there are.