Updated 011 Component Scripts (markdown)
parent
092fd32630
commit
0dfb612eb2
@ -3,27 +3,27 @@
|
|||||||
[00:00:00](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
|
[00:00:00](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
|
||||||
(_Click on these time links to see Youtube video_)
|
(_Click on these time links to see Youtube video_)
|
||||||
|
|
||||||
Now we will look at the scripts tab. Here is an area where you might add a lot of custom scripting. This area is focused on giving your area an interface to add custom scripting to your component in a global way. You can have custom scripting per admin back end view. [00:00:28](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m28s) You can also do that within the global scope with regards to certain values and add create user helper method to the component.
|
Now we will look at the scripts tab. Here is an area where you might add a lot of custom scripting. This area is focused on giving your area an interface to add custom scripting to your component in a global way. You can have custom scripting per admin back end view. [00:00:28](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m28s) You can also do that within the global scope with regards to certain values and add create a user helper method to the component.
|
||||||
|
|
||||||
### Create User Helper Method
|
### Create User Helper Method
|
||||||
|
|
||||||
[00:00:47](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m47s)
|
[00:00:47](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m47s)
|
||||||
|
|
||||||
The 'user helper method' is simply code. If you don't know how to write PHP this method will be of no use to you. If you do, this method will come in very handy. Let me illustrate that to you. I have a component in which I've already implemented this feature. It's called the 'cost-benefit projection tool'. If you click on companies, you can click 'new'. [00:01:19](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m19s) It has an area for you to create a company.
|
The 'user helper method' is code. If you don't know how to write PHP this method will be of no use to you. If you do, this method will come in very handy. Let me illustrate that to you. I have a component in which I've already implemented this feature. It's called the 'cost-benefit projection tool'. If you click on companies, you can click 'new'. [00:01:19](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m19s) It has an area for you to create a company.
|
||||||
|
|
||||||
### Example Helper Method(Create User)
|
### Example Helper Method(Create User)
|
||||||
|
|
||||||
[00:01:29](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m29s)
|
[00:01:29](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m29s)
|
||||||
|
|
||||||
Ideally you would connect that company to a user in the system. (It might be that you won't add that company to a user because a user can have multiple companies.) If you click on 'select user', you could select the user. [00:01:49](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m49s) But if you haven't selected a user, and have entered an email address, a name, and the needed information, then when you close or save the system will create a user for you and will automatically email the user details to that user. This is because of that specific helper class that I added. [00:02:14](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m14s) It doesn't do it on its own; you need to write the code for it. Let me show you where I did it in the controller. (See video.) If we open up company there is an area called: 'PostsaveHook'. [00:02:38](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m38s) When we looked at the admin views we could target this area. That is what I did.
|
Ideally, you would connect that company to a user in the system. (It might be that you won't add that company to a user because a user can have multiple companies.) If you click on 'select user', you could select the user. [00:01:49](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m49s) But if you haven't selected a user, and have entered an email address, a name, and the needed information, then when you close or save the system will create a user for you and will automatically email the user details to that user. This is because of that specific helper class that I added. [00:02:14](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m14s) It doesn't do it on its own; you need to write the code for it. Let me show you where I did it in the controller. (See video.) If we open up 'company' there is an area called: 'PostsaveHook'. [00:02:38](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m38s) When we looked at the admin views we could target this area. That is what I did.
|
||||||
|
|
||||||
This is how we go about it: Go in the 'admin view' for 'company'. If you go to PHP you'd see some Ajax there and an area which is the 'postsavehook method'. [00:03:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m03s) In the postsavehook method, I'm checking some values. If the user does not exist, A check is done, then the 'create user' used. (See video.) [00:03:41](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m41s) This placeholder convention had been mentioned before. Here you use the brackets convention, not the # one.'[[[Component]]]Helper.' This will be replaced with the component's code name. It gets the helper class, create_user. If this is closed in the helper class of this component, go to the helper and open the 'helper class'. [00:04:13](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m13s) The component's name is 'costbenefitprojection' and is called helper. In helper class there is a feature called 'create_user'. [00:04:39](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m39s) It gets an array in it, and that array has values which we will be using, like password 1, password 2. It will set the password. This shows you where the function is. The function was added to the components helper class and in that script, I'm calling that function after having build the user. I set the array as 'name' and the email as 'validData'. The function, if there is no password set, will set a random password and use another method. This 'random method' where you can get a random string is part of the helper class we've exported with all helper classes. [00:05:28](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m28s) It creates a user, sets up the password, and then gets the array ready. It gets a model. I got the model from there, 'getmodel'. Once more we are using a component builder custom method. It gets the specific model from the system then fires the register method upon this dataset and updates the parameters for the system regarding this new user. [00:06:11](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m11s) It sends the email and returns the ID. [00:06:41](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m41s) We need the ID. If you don't have the ID, it will send a message to the user; if we have the ID, it will store it into that database to connect that item to that user automatically. Save.
|
This is how we go about it: Go in the 'admin view' for 'company'. If you go to PHP you'd see some Ajax there and an area which is the 'postsavehook method'. [00:03:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m03s) In the 'postsavehook method,' I'm checking some values. If the user does not exist, A check is done, then the 'create user' used. (See video.) [00:03:41](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m41s) This placeholder convention had been mentioned before. Here you use the brackets convention, not the # one.'[[[Component]]]Helper.' This will be replaced with the component's code name. It gets the helper class, create_user. If this is closed in the helper class of this component, go to the helper and open the 'helper class'. [00:04:13](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m13s) The component's name is 'costbenefitprojection' and is called helper. In helper class, there is a feature called 'create_user'. [00:04:39](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m39s) It gets an array in it, and that array has values which we will be using, like password 1, password 2. It will set the password. This shows you where the function is. The function was added to the components helper class and in that script, I'm calling that function after having built the user. I set the array as 'name' and the email as 'validData'. The function, if there is no password set, will set a random password and use another method. This 'random method' where you can get a random string is part of the helper class we've exported with all helper classes. [00:05:28](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m28s) It creates a user, sets up the password, and then gets the array ready. It gets a model. I got the model from there, 'getmodel'. Once more we are using a component builder custom method. It gets the specific model from the system then fires the register method upon this dataset and updates the parameters for the system regarding this new user. [00:06:11](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m11s) It sends the email and returns the ID. [00:06:41](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m41s) We need the ID. If you don't have the ID, it will send a message to the user; if we have the ID, it will store it into that database to connect that item to that user automatically. Save.
|
||||||
|
|
||||||
### Add UIKit
|
### Add UIKit
|
||||||
|
|
||||||
[00:07:01](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m01s)
|
[00:07:01](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m01s)
|
||||||
|
|
||||||
This switch adds the method to your helper class. (See video.) Whereas this switch adds the Uikit library to your media folder as well as integrates it dynamically wherever you use the Uikit class names. You won't need to write it in any custom way; it automatically adds it. The same goes with FooTable.
|
This switch adds the method to your helper class. (See video.) Whereas this switch adds the Uikit library to your media folder as well as integrates it dynamically wherever you use the Uikit class names. You won't need to write it in any custom way; it automatically adds it. The same goes for FooTable.
|
||||||
|
|
||||||
### Add Global CSS To Admin Back End
|
### Add Global CSS To Admin Back End
|
||||||
|
|
||||||
@ -41,13 +41,13 @@ This is a place for you to add your own custom scripting to the helper_admin Cla
|
|||||||
|
|
||||||
[00:08:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m03s)
|
[00:08:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m03s)
|
||||||
|
|
||||||
This event concept has been mentioned before, but this is what we want to achieve with the event. In the back end part of 'sermon distributor' there is a file. It is the in main file which Joomla calls 'first', and in that file it triggers that global admin event. The global admin event is nothing but a function inside of your helper function. It always triggers it if you add that switch and passes the document object. [00:08:40](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m40s) The document object is being built up here. I'm passing it over to the global event. There is no need to clear it. If you open the helper class and scroll to the top, it says loaddropboxajax'. [00:09:08](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m08s) This is just another function. I wrote it so that you can add whatever functions you want to run globally every time a page opens. It can run like a chronicle task on the front and the back end of the component. If you have things that you want to be done chronically, this feature is targeted to do that. [00:09:35](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m35s) For instance, we are loading the 'LoadDropboxAjax'. If we go back to the component, you'd see that I am adding that script. First I clicked global admin event 'yes' and added the script. That's all they added. The script was taken and placed inside the global event. The trigger'globalevent' is set by component builder; you don't need to write it. [00:10:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m03s) It will insert this 'globalevent' trigger because you clicked 'yes'. Then you need to add the script that must run inside of the global event. This function, which I want to run, I added to the admin view at the admin helper class. [00:10:29](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m29s) I used the 'loadDropboxAjax' name, and called it 'self', because we are inside of the class. That's how you call 'static class method' and pass same information. In my method I'm adding JavaScript to the document object. I want that document and then I set 'addScriptDeclaration'. [00:10:59](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m59s) It means that on every page of this component in the back end, this little script is added which then calls by Ajax and checks the Dropbox listing automatically. This automatic feature had been added to the component so that you can do the same in other components. That's the purpose of the event switch. The same is applicable to the site area. [00:11:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m37s)
|
This event concept has been mentioned before, but this is what we want to achieve with the event. In the back end part of 'sermon distributor' there is a file. It is the in the main file which Joomla calls 'first', and in that file, it triggers that global admin event. The global admin event is nothing but a function inside of your helper function. It always triggers it if you add that switch and passes the document object. [00:08:40](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m40s) The document object is being built up here. I'm passing it over to the global event. There is no need to clear it. If you open the helper class and scroll to the top, it says loaddropboxajax'. [00:09:08](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m08s) This is just another function. I wrote it so that you can add whatever functions you want to run globally every time a page opens. It can run like a chronicle task on the front and the back end of the component. If you have things that you want to be done chronically, this feature is targeted to do that. [00:09:35](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m35s) For instance, we are loading the 'LoadDropboxAjax'. If we go back to the component, you'd see that I am adding that script. First I clicked global admin event 'yes' and added the script. That's all they added. The script was taken and placed inside the global event. The trigger'globalevent' is set by Component Builder; you don't need to write it. [00:10:03](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m03s) It will insert this 'globalevent' trigger because you clicked 'yes'. Then you need to add the script that must run inside of the global event. This function, which I want to run, I added to the admin view at the admin helper class. [00:10:29](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m29s) I used the 'loadDropboxAjax' name, and called it 'self' because we are inside of the class. That's how you call 'static class method' and pass the same information. In my method, I'm adding JavaScript to the document object. I want that document and then I set 'addScriptDeclaration'. [00:10:59](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m59s) It means that on every page of this component in the back end, this little script is added which then calls by Ajax and checks the Dropbox listing automatically. This automatic feature had been added to the component so that you can do the same in other components. That's the purpose of the event switch. The same is applicable to the site area. [00:11:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m37s)
|
||||||
|
|
||||||
### Add Custom PHP Helper Site View
|
### Add Custom PHP Helper Site View
|
||||||
|
|
||||||
[00:11:44](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m44s)
|
[00:11:44](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m44s)
|
||||||
|
|
||||||
Why are there different helper classes for the front and the back? It's about security and permissions. For example, there are things that I want to do in the back end where many questions aren't asked; on the front I might be more protective. Hence the implementation is often different in the front than in the back. That's why we have two different files: the Helpers site class and the Helper admin class where custom scripting can be added. [00:12:09](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m09s) I added the same script to the front and added a site event which triggers it. What if everybody could trigger the script? Is it going to run multiple times? [00:12:32](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m32s) The answer is that it is exactly part of what has been done. I added a feature in the Ajax call that logs whether it's active or not. If it is active, it ignores that call. It has a controller determining whether it should run or not and a timer that you can set for the sermon distributor. [00:12:56](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m56s) You can set how often you want Dropbox links to be updated, or whether it wants to update or not. Since it's Ajax the user himself don't even notice a delay in his page. The page opens as fast as it always do and fires that Ajax call to the server which will start the whole process on the server. This is all possible inside of component builder through these custom areas.
|
Why are there different helper classes for the front and the back? It's about security and permissions. For example, there are things that I want to do in the back end where many questions aren't asked; on the front, I might be more protective. Hence the implementation is often different in the front than in the back. That's why we have two different files: the Helpers site class and the Helper admin class where custom scripting can be added. [00:12:09](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m09s) I added the same script to the front and added a site event which triggers it. What if everybody could trigger the script? Is it going to run multiple times? [00:12:32](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m32s) The answer is that it is exactly part of what has been done. I added a feature in the Ajax call that logs whether it's active or not. If it is active, it ignores that call. It has a controller determining whether it should run or not and a timer that you can set for the sermon distributor. [00:12:56](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m56s) You can set how often you want Dropbox links to be updated, or whether it wants to update or not. Since it's Ajax the user himself don't even notice a delay in his page. The page opens as fast as it always does and fires that Ajax call to the server which will start the whole process on the server. This is all possible inside of component builder through these custom areas.
|
||||||
|
|
||||||
### Add MySQL Dump
|
### Add MySQL Dump
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ You can also add a SQL dump. Instead of adding it to the actual views you can e
|
|||||||
|
|
||||||
[00:14:23](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m23s)
|
[00:14:23](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m23s)
|
||||||
|
|
||||||
Let me show you what I've done with dashboard methods. All this data that I'm showing you is dummy. (See video.) It is not related to the application but I'm just testing it. I wanted to add this usage statistics to the component, so you can see which country has done what, when, and in what area. I took a lot of different database tables and calculated by using certain ways. I wanted to have that on the dashboard. The dashboard have all these icons already. I didn't want it to add another custom view. [00:14:53](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m53s) I wanted it right there at the moment of the page load. So we added this feature to Component Builder and called it dashboard methods.
|
Let me show you what I've done with dashboard methods. All this data that I'm showing you is imitation. (See video.) It is not related to the application but I'm just testing it. I wanted to add this usage statistics to the component, so you can see which country has done what, when, and in what area. I took a lot of different database tables and calculated by using certain ways. I wanted to have that on the dashboard. The dashboard has all these icons already. I didn't want it to add another custom view. [00:14:53](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m53s) I wanted it right there at the moment of the page load. So we added this feature to Component Builder and called it dashboard methods.
|
||||||
|
|
||||||
I created a method called 'getusagedata'. [00:15:26](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m26s) It's a public function method inside which I added my script. Inside this script I'm calling other methods which I made to protect 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 'Table.' (See video.) [00:16:01](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) Here is the 'HTML' which we are using. In the HTML you see PHP. We do it with that convention of '<?php echo,' then closing it there '>?' and checking whether the usage data is there.
|
I created a method called 'getusagedata'. [00:15:26](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m26s) It's a public function method inside which I added my script. Inside this script, I'm calling other methods which I made to protect the script that must be called from the dashboard tab. You set that up here. ('Dashboard Tab -Add'.) Here is the tab and it's HTML. We called the tab 'Usage Statistics' and the header 'Table.' (See video.) [00:16:01](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m01s) Here is the 'HTML' which we are using. In the HTML you see PHP. We do it with that convention of '<?php echo,' then closing it there '>?' and checking whether the usage data is there.
|
||||||
|
|
||||||
How do I know that I should target 'this usage data' and the 'items'? This area 'usagedata' is a convention area. The convention works by this one here. (See video.) [00:16:46](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m46s) '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->' without the 'get' name. [00:17:15](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The convention is that you could have called that 'get', the "manonthemoon". Then this would be 'manonthemoon', all in lowercase. The 'get' will be dropped and this 'UsageData' will be used lowercase like the 'this'. [00:17:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m37s) I know the convention might not be that obvious, but it works. If your other functions are protected they should not have the word 'get' in them. (See video.)
|
How do I know that I should target 'this usage data' and the 'items'? This area 'usagedata' is a convention area. The convention works by this one here. (See video.) [00:16:46](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m46s) '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->' without the 'get' name. [00:17:15](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The convention is that you could have called that 'get', the "manonthemoon". Then this would be 'manonthemoon', all in lowercase. The 'get' will be dropped and this 'UsageData' will be used lowercase like the 'this'. [00:17:37](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m37s) I know the convention might not be that obvious, but it works. If your other functions are protected they should not have the word 'get' in them. (See video.)
|
||||||
|
|
||||||
@ -69,8 +69,8 @@ How do I know that I should target 'this usage data' and the 'items'? This area
|
|||||||
|
|
||||||
[00:18:06](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m06s)
|
[00:18:06](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m06s)
|
||||||
|
|
||||||
A lot of PHP can be added here, all of which together gets the data that is needed on the page. When all the data is collected it is placed in 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 these sub functions. The name, 'items' is added in one of them as a pointer; 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. Here you are able to target 'items' as an object; if it exist and is set you can start looping through items and certain places in which you are using totals and different values. [00:19:45](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m45s)
|
A lot of PHP can be added here, all of which together gets the data that is needed on the page. When all the data is collected it is placed in 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 these sub-functions. The name, 'items' is added in one of them as a pointer; it is an 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. Here you are able to target 'items' as an object; if it exists and is set you can start looping through items and certain places in which you are using totals and different values. [00:19:45](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m45s)
|
||||||
|
|
||||||
This could have been simple. You could have left this out completely and only placed a comment. You could have done this. (See video.) You can set it 'not needed' and 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, you might like to run a RSS feed here. (See video.) [00:20:34](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m34s) You can reach into PHP here, and the PHP that you reached in has the convention of dropping the get and using the front area, 'usage data', to place information in which you can parse your HTML as you would do in any other component view.
|
This could have been simple. You could have left this out completely and only placed a comment. You could have done this. (See video.) You can set it 'not needed' and 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, you might like to run an RSS feed here. (See video.) [00:20:34](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m34s) You can reach into PHP here, and the PHP that you reached has the convention of dropping the get and using the front area, 'usage data', to place information in which you can parse your HTML as you would do in any other component view.
|
||||||
|
|
||||||
This has been a quick overview of the script area of a component. It might come in very useful if you are a developer enabling you to add custom scripting to a component through these methods. [00:21:27](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m27s)
|
This has been a quick overview of the script area of a component. It might come in very useful if you are a developer enabling you to add custom scripting to a component through these methods. [00:21:27](https://www.youtube.com/watch?v=xY9TWQrF8AQ&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m27s)
|
||||||
|
Loading…
Reference in New Issue
Block a user