Updated 008 Advanced Fields (markdown)

Amigo 2019-06-05 08:46:08 +02:00
parent 49eb49efdb
commit 26604992ed

@ -63,23 +63,16 @@ This part here means that you can add a helper static method call in your custom
Now to add methods [00:25:09](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m09s) to the helper files. If you want to know what all the custom helpers is that we ship with all components, you can open component builder. You can go to the compiler and to Joomla 3 and 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 will see a whole lot of helper methods. Obviously with a lot of place holders which we will customized for each component that it targets that component. You would see there is a Json to string method here just to 'getvars'. There's a 'getvar' singular. This is just to get one variable from the database so you don't need to to rewrite [00:25:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m55s) this whole string to get just one variable. You can come and look at how this works and use this 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) This is way beyond the scope of just looking at custom fields. We will go into great depth into all the features of a helper structures when we deal with advanced concepts. This is just a heads up so that you can start looking at it and possibly get yourself going. I wrote these functions, checkobject, checkarray, checkstring, [00:26:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m40s) checkJson, shorten, mergearrays, savestring, and HTMLescape, replacenumbers, this one I'm using quite often. If you do savestring [00:26:58](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m58s) we change every number in the string immediately to text, so that you can be sure whatever you get back from savestring doesn't have numbers in it. This is quite necessary especially if you don't know if the first character might be a number. [00:27:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m20s) In this way we are insuring that it is always text. Now to add methods [00:25:09](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m09s) to the helper files. If you want to know what all the custom helpers is that we ship with all components, you can open component builder. You can go to the compiler and to Joomla 3 and 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 will see a whole lot of helper methods. Obviously with a lot of place holders which we will customized for each component that it targets that component. You would see there is a Json to string method here just to 'getvars'. There's a 'getvar' singular. This is just to get one variable from the database so you don't need to to rewrite [00:25:55](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m55s) this whole string to get just one variable. You can come and look at how this works and use this 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) This is way beyond the scope of just looking at custom fields. We will go into great depth into all the features of a helper structures when we deal with advanced concepts. This is just a heads up so that you can start looking at it and possibly get yourself going. I wrote these functions, checkobject, checkarray, checkstring, [00:26:40](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m40s) checkJson, shorten, mergearrays, savestring, and HTMLescape, replacenumbers, this one I'm using quite often. If you do savestring [00:26:58](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m58s) we change every number in the string immediately to text, so that you can be sure whatever you get back from savestring doesn't have numbers in it. This is quite necessary especially if you don't know if the first character might be a number. [00:27:20](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h27m20s) In this way we are insuring that it is always text.
<Editted
**Strings** **Strings**
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 here. Getactions, shortenstring, mergearray. So you can come and any of you feel that the methods that I have used here is archaic or outdated, [00:28:00](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h28m00s) please go on the forums at Github and talk with me about it. I will gladly look at it and see. 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 there might be an easier way. Obviously we first want to ensure that it's set. That this value is set. And then it is a string and then it actually has a length you see something can be a string and yet don't have a length. [00:29:04](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h29m04s) I might be wrong on that and yet this is what I found. I've only been coding and PhP for 3 years now. You can teach me a few things. You have been at it longer than I am. 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. Showing it to you in here, go up a bit [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 of 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 returns one specific sermons link. This method is quite dynamic. That is all that I'm 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 just load like I have explained. That is again as you can see quite advanced implementation of this custom fields. [00:30:37](https://www.youtube.com/watch?v=VpzYbifqv0M&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h30m37s) I hope you would realize, there you can do anything. With that list conception you could 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. That would be the custom fields.
**Custom User** **Custom User**