From 4d7c87a2da6aed3dbc2c04c49d26cd14af718906 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Wed, 22 May 2019 16:07:28 +0200 Subject: [PATCH] Updated 007 Admin Views (markdown) --- 007-Admin-Views.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/007-Admin-Views.md b/007-Admin-Views.md index eba2419..9c25ce3 100644 --- a/007-Admin-Views.md +++ b/007-Admin-Views.md @@ -86,8 +86,21 @@ Then there is a PHP area and here you have the option of adding JavaScript to yo Here you can see that if you know the Joomla API, you know that it has a (getitem method) [01:10:45](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h10m45s), it has a (getitems method) in the model. In the model there's a (getitem method) in the editing model. In the list model there is a (getitems method). Then there's a (getlistquery) in the (jmodellist). And there is a (safe method), there's a (postsavehook method) in the controller. There is (allowedit method). [01:11:10](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m10s) -There's a (batchcopy method). There's a (batchmove method). There's a (script before delete) method. There's a (script after delete). And these are all PHP places in which you can dump custom scripting. So if you want the save method, [01:11:32](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m32s) you need to know where the save method is, so if I would open sermon here, scroll down to get item. So you can add custom scripting to the get item method. [01:12:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m06s) -There is save method and so if we go back here and we click on the save method, it says here, that should run PHP here, that should run in the save method. And then you have the data, it's a array and it's called [01:12:27](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m27s) data. So If you look here it means you're able to target that value. It gets placed into save. +There's a (batchcopy method). There's a (batchmove method). There's a (script before delete) method. There's a (script after delete). These are all PHP places in which you can dump custom scripting. +**Save Method** - And I am sure that your custom [01:12:47](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m47s) value code will be placed in before the parents saved But if you do not If you do not know in any of those Custom scripts Where that code will be set What you can do is just type It is [01:13:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m06s) Loaded Here And then compile save it and compile the component and then go look at the code And you see where it is showing up And then you can add Ok I've got all these values already In the script Because all that component builder is gonna do it's just gonna Let's say It will just say [01:13:37](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m37s) That's that's how it will look It'll just add to string so when the component itself runs it will treated as code This is a comment but I mean if it was code You just execute So it is the way for you to add custom scripting Right into your component Almost anywhere really You are able to Target Through these switches The post save hook [01:14:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m05s) Is actually in the controller not in the model So You go to the controller Sermon Scroll to the bottom And you see there is a post save hook And it basically gives you the model and it gives you the valid data and you can Actually can perform extra features on it [01:14:27](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m27s) But in all these things You you should just read the description here it says PHP here that should run in the post Save hook method And there's the object model is the data model Object and the erased validator is the validator So if you just read our little note here Then you can start coding For it Ok That is so adding custom scripting To the view [01:14:55](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m55s) Basically the list view as well as the Each View And then the MySQL dump area Which we looked at earlier You can do two kinds of dumps now What is this used mostly for Well what I found while I was Busy developing That I would be Busy setting up a component [01:15:15](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m15s) and install it and then add dummy data to it to see if it works And then every time I make a change And I uninstall that component and install the new one Because whatever change it made to the database Won't be You're not added to the database via an update You need to uninstall the component and install it again To get the database back to where you want it And so the only way I could do save myself [01:15:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m43s) Time Is to actually say listen I'm gonna Re-install this component and the dummy data for sermons I would like to retain And so I would go table and I Open the tables it will show me a list of all the Tables that are in the database at that moment And then I would scroll to sermon the Sermon table click on it [01:16:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m06s) And it will load The table and What it should be called In the data set Here is some explanation if you want to do Other tables so let's say you wanna have it mapped to multiple tables then this is the explanation on how to Do that I would not recommend doing this because possibly You will not get [01:16:29](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m29s) What you expect And so Just going with the values that it populates for you will Possibly your best call Unless those values change And if you are making changes adding new fields You must realise that you need to come and reset this by clicking on something else And then clicking on it again And that it loads the new [01:16:57](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) list of Fields that are related to this table To this Back end view Table And that way When you compile the component then component builder will actually grab the data From the database and build a dump file for you Now that is one way of doing it [01:17:18](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m18s) I might be a little bit complex but it is saved Tons of hours The other way would be to just do a dump file itself So you'd go to Your Your MySQL you would open the specific let's Use this thing that is Smaller Field types [01:17:40](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m40s) And you click on Export And then you would select A sequel format And click go And this will create a dump file Of all the data in the table And you can basically Paste that dump file in here Now [01:18:17](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m17s) I was looking at Important So you click export click quick Then SQL and then Go And then just save it Then Go to that file Open it And having it open [01:18:41](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m41s) You just replace This String With Hash Underscore So and then replace all And you will not use the table Structure because that is already in component builder You just use [01:19:03](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m03s) This area here Basically you would copy this Area like That Cut Come here paste And click save And that will mean that you have to dump file And it will always be added [01:19:36](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m36s) To your new Install If a dump file is way too big You will see it by just after your clicked save come and look At the end And see if it cut it off somewhere So let's say it cut it off there that I know my dumb file is To big for the use [01:20:04](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m04s) Structure For your dump File I used medium text let's see medium text Here Prosafe There it is Sequel I used medium text [01:20:39](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m39s) So that means It's quite big You can really put a lot of Text inside of it You wanna know exactly how much just Google it and you will see I'm gonna remove this obviously because It's not related to sermons at all And [01:20:57](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m57s) In fact I'm not even go to use the dump here, save and close Ok That is basically setting up an admin View I know I've run around and it seemed quite hectic And I possibly will redo this video at a certain stage Try to be Structured But I think it is informative enough [01:21:20](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m20s) And if you Have any questions please email me and I will Try to communicate with you And if I see that a certain question comes up often enough I will add it to the Video Possibly redoing Specific area [01:21:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m35s) Admin views is quite intense And we will possibly revisit many of the Concepts that we have looked at today Thank you for watching +If you want the save method, [01:11:32](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h11m32s) you need to know where the save method is, so if I would open sermon here, scroll down to get item. So you can add custom scripting to the get item method. [01:12:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m06s) +There is save method and so if we go back here and we click on the save method, it says here, that should run PHP here, that should run in the save method. And then you have the data, it's a array and it's called [01:12:27](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m27s) data. So If you look here it means you're able to target that value. It gets placed into save. And I am sure that your custom [01:12:47](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h12m47s) value code will be placed in before the parent saved. But if you do not know in any of those custom scripts where that code will be set. What you can do is just type: it is [01:13:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m06s) loaded here. Save it and compile the component and then go look at the code. And you will see where it is showing up. And then you can add and say I've got all these values already in the script, because all that component builder is going to do it's just going to dump, let's say, (it is loaded here) [01:13:37](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h13m37s) That is how it will look. It'll just add the string. So when the component itself runs it will treated as code. This is a comment but I mean if it was code. It will just execute. So it is the way for you to add custom scripting right into your component almost anywhere. You are able to target through these switches. + +**Post Save Hook** + +The post save hook [01:14:05](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m05s) is actually in the controller not in the model. So You go to the controller sermon. Scroll to the bottom and you see there is a (postsavehook). It basically gives you the model and it gives you the valid data and you can actually can perform extra features on it. [01:14:27](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m27s) But in all these things you should just read the description. It says "PHP here that should run in the postSavehook Method and there is the (object)$model is the data model object and (array) validated data". So if you just read our little note here, then you can start coding for it. That is adding custom scripting to the view. [01:14:55](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h14m55s) Basically the list view as well as each view and then the MySQL dump area which we looked at earlier. + +**Dump File** + +You can do two kinds of dumps. What is this used mostly for? Well what I found while I was busy developing that I would be busy setting up a component [01:15:15](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m15s) and install it and then add dummy data to it to see if it works. And then every time I make a change and I uninstall that component and install the new one because whatever change it made to the database won't be added to the database via an update. You need to uninstall the component and install it again to get the database back to where you want it. And so the only way I could save myself [01:15:43](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h15m43s) time, is to actually say listen I'm going to re-install this component and the dummy data for sermons. I would like to retain. So I would go to table and I open the tables. It will show me a list of all the tables that are in the database at that moment. And then I would scroll to sermon table. Click on it [01:16:06](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m06s) and it will load the table and what it should be called in the data set. Here(Source Map) is some explanation if you want to do other tables. Let's say you want to have it mapped to multiple tables, then this(Source Map) is the explanation on how to do that. I would not recommend doing this because possibly you will not get [01:16:29](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m29s) what you expect. And just going with the values that he populates for you, will possibly your best call, unless those values change and if you are making changes adding new fields. You must realize that you need to come and reset this by clicking on something else. And then clicking on it again and that it loads the new [01:16:57](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h16m57s) list of fields that are related to this table to this back end view table. And that way when you compile the component then component builder will actually grab the data from the database and build a dump file for you. + +**Dump File Itself** + +Now that is one way of doing it [01:17:18](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m18s) I might be a little bit complex but it is saved tons of hours The other way would be to just do a dump file itself. So you'd go to your MySQL, you would open the specific, let's use smaller field types. [01:17:40](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h17m40s) Click on export and then you would select SQL format and click 'go'. And this will create a dump file of all the data in the table. And you can basically paste that dump file in here Now [01:18:17](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m17s) I was looking at Important So you click export click quick Then SQL and then Go And then just save it Then Go to that file Open it And having it open [01:18:41](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h18m41s) You just replace This String With Hash Underscore So and then replace all And you will not use the table Structure because that is already in component builder You just use [01:19:03](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m03s) This area here Basically you would copy this Area like That Cut Come here paste And click save And that will mean that you have to dump file And it will always be added [01:19:36](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h19m36s) To your new Install If a dump file is way too big You will see it by just after your clicked save come and look At the end And see if it cut it off somewhere So let's say it cut it off there that I know my dumb file is To big for the use [01:20:04](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m04s) Structure For your dump File I used medium text let's see medium text Here Prosafe There it is Sequel I used medium text [01:20:39](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m39s) So that means It's quite big You can really put a lot of Text inside of it You wanna know exactly how much just Google it and you will see I'm gonna remove this obviously because It's not related to sermons at all And [01:20:57](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h20m57s) In fact I'm not even go to use the dump here, save and close Ok That is basically setting up an admin View I know I've run around and it seemed quite hectic And I possibly will redo this video at a certain stage Try to be Structured But I think it is informative enough [01:21:20](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m20s) And if you Have any questions please email me and I will Try to communicate with you And if I see that a certain question comes up often enough I will add it to the Video Possibly redoing Specific area [01:21:35](https://www.youtube.com/watch?v=CdSKSCTzmRA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=01h21m35s) Admin views is quite intense And we will possibly revisit many of the Concepts that we have looked at today Thank you for watching