From e0949569ab03c6485ef5063fb35398e566d1e327 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Tue, 11 Jun 2019 08:55:28 +0200 Subject: [PATCH] Updated 011 Component Scripts (markdown) --- 011-Component-Scripts.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/011-Component-Scripts.md b/011-Component-Scripts.md index dc43f85..2aa6bb1 100644 --- a/011-Component-Scripts.md +++ b/011-Component-Scripts.md @@ -45,14 +45,6 @@ Then we have this nice feature called dashboard methods. Let me show you what I' I could spend more time in explaining and less on typing. I created a [00:15:26](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m26s) method called 'getusagedata'. It's a public function method and inside it I added my script. Inside of this script I'm calling other methods which I made it protected. the script that must be called from the dashboard tab. You set that up here'Dashboar Tab -Add'. Here is the tab, and it's HTML. We called the tab 'Usage Statistics' and the header we made 'Table', [00:16:01](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) and here(see video) is the 'HTML'. Which we are using. and in the HTML you see PHP and the way we do that is with that convention of '?' and checks whether the usage data is there. -How do I know that I should target 'this usage data' and then 'items'? Well, this area 'usagedata' is a convention area. The way that, that convention works, is [00:16:46](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m46s) by that one there. 'Usage data' relates to 'usage data'(see video).<<<<<<<<<<<<< +How do I know that I should target 'this usage data' and then 'items'? Well, this area 'usagedata' is a convention area. The way that, that convention works, is [00:16:46](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m46s) by that one there. (see video). So'Usage data' relates to 'usage data'.The moment you add the word 'get', in front of a function, it will be added to a 'global', the result of that 'get' will be added to '$this->' and without the 'get' name, so that is the convention. [00:17:15](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The convention is you could've called that 'get', 'manonthemoon'. Then this would be 'manonthemoon' all in lowercase. That(get) will be dropped and this(UsageData) is going to be used lowercase, just as the 'this'. [00:17:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m37s) That's the convention. I know it might not be that obvious but it works. So your other functions, if they are protected shouldn't have the word 'get' in it. At the moment it's set, to 'set'. That one is set, this one is 'visitcheck'. This one is set 'companies' and set 'countries'. [00:18:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) - - - - - The moment you add the word 'get', in front of a function, it will be added to a global, the result of that 'get' will be added to 'this' and without the 'get' name, so that the convention. [00:17:15](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The convention is you could've called that 'get' 'manonthemoon'. Then this would be 'manonthemoon' all in lowercase. That(get) will be dropped and this(UsageData) is going to be used lowercase, just as the 'this'. [00:17:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m37s) That's the convention. I know it might not be that obvious but it works. So your other functions, if they are protected shouldn't have the word get in it. At the moment it's set, to 'set'. That one is set, this one is 'visitcheck'. This one is set 'companies' and set 'countries'. [00:18:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) - -I could add a lot of PHP in here. And all these PHP together gets the data that we want on the page. When I get the data I placed it in what is seen as the item. I'm returning a field here or a method value. [00:18:43](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m43s) This method value is being populated in this sub functions. And in one of them it is adding over here, the name items as a pointer. So it becomes an object, it is an object in fact I think I set it is an object up here. [00:19:09](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m09s) Then I look through the companies, and as I look through them I'm busy totaling and adding and going on. I'm not going explain the code itself, but this(usagedata) is getting returned, because it's an object. If I look here I'm able to target 'items' as an object. Then if it's exist, if it's set, I start looping through items and certain places I'm using totals and different values. That is just adding some of that data to the page. [00:19:45](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m45s) And this area here. - -Now I could have made this much simpler right so maybe not look that intense to you. But this could have been a simple class. In fact you could have let this out completely. And just put a comment. You could have done this(see video). You can set it 'not needed' and then in here(Dashboard Tab - Add) you could just do HTML. If you just want to give information to the user about, who made the component, maybe some would like to run a rss feed here, you could have done it right here. I'm just showing you that you can reach into PHP here, and that the PHP that you reach in, has the convention [00:20:34](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m34s) of dropping the get and then using that front area, usage data, to place information in which you can parse in your HTML here. That you would do in any other component view. That is just quickly looking at the script area of a component. I realize there's so much more to say but I really can't elaborate too much on this. Since it requires skill in PHP. It's something that I think will only become very useful if you are a developer, as developed a few components. And then see how you can easily add custom scripting to his component through this methods. Well next up will look at the ReadMe, [00:21:27](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m27s) and maybe their FTP server concepts. +A lot of PHP can be added in here and all these PHP together gets the data that is needed on the page. When all the data is collected it is placed in what is seen as the 'item'. A field or a method value is returned. [00:18:43](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m43s) This method value is being populated in this sub functions and in one of them is added the name, 'items' as a pointer and it is a object. [00:19:09](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m09s) The code itself will not be explained right now, but this'usagedata' is getting returned, because it's an object. If you look here you are able to target 'items' as an object and if it exist, if it is set, you can start looping through items and certain places you are using totals and different values. That is just adding some of that data to the page. [00:19:45](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m45s) This could have been a simple class, in fact you could have left this out completely and could only put a comment. You could have done this(see video). You can set it 'not needed' and then in here 'Dashboard Tab - Add' you can do HTML. If you just want to give information to the user concerning the person who made the component, maybe some would like to run a RSS feed here(See video), you could have done it right here. [00:20:34](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m34s) I'm just showing you that you can reach into PHP here, and that the PHP that you reached in, has the convention of dropping the get and then using that front area, 'usage data', to place information in which you can parse in your HTML as you would do in any other component view. This has been just a quick overview of the script area of a component. It's something that might become very useful if you are a developer, to inable you to add custom scripting to a component through this methods. In the next tutorial we will look at 'ReadMe' and maybe their FTP server concepts. [00:21:27](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m27s)