Updated 055 Dynamic File and Folder Inclusion concept (markdown)

Amigo 2019-09-06 15:02:57 +02:00
parent 36459d2bfc
commit 5a82ed0b56

@ -13,27 +13,25 @@ I am working with components that are pulling data from all over the place. Most
[00:02:24](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m24s)
There is now a new area called 'Advance'. [00:02:35](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m35s) The 'Advance' area is able to grab files from anywhere in your system an add it to the component. It can be files outside of the root directory of your Joomla website. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
There is now a new area called 'Advance'. [00:02:35](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m35s) The 'Advance' area is able to grab files from anywhere in your system an add it to the component. It can be files outside of the root directory of your Joomla website.
### Note - Adding Files
[00:02:53](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m53s)
Just make sure that the PHP has the right to the file and can read it(See Video). But for most cases it is not necessary to grab files outside the Joomla root directory, because we are just editing a custom file inside of our Joomla Component which we have created. [00:03:24](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m24s) But this file or this folders are not generated by JCB. We want those files where they are actively running inside of our component. We want them to be taken and put into the package without us having to move it around. So you can like a I am doing here(see video). [00:03:52](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m52s), There is a note; '_Please note... use constant paths_'. That you can use constant paths and the full path directly without quotes. That means you do not need to do like in PHP,(follow on video) <<<<<<<<<
you do something like that, and you put this part in quotes, like that. Well you don't need to do any of that. You put the constant directly like that and the compiler will deal with this [00:04:21](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) and make it right. You can do that also with folders as well as with files.
Just make sure that the PHP has the right to the file and can read it(See Video). But for most cases it is not necessary to grab files outside the Joomla root directory, because we are just editing a custom file inside of our Joomla Component which we have created. [00:03:24](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m24s) But this file or this folders are not generated by JCB. We want those files where they are actively running inside of our component. We want them to be taken and put into the package without us having to move it around. So you can like a I am doing here(see video). [00:03:52](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m52s), There is a note; '_Please note... use constant paths_'. That you can use constant paths and the full path directly without quotes. That means you do not need to do like in PHP,(follow on video) you put this part in quotes. Well you do not need to do any of that. You can put the constant directly like that and the compiler will deal with this and make it right.[00:04:21](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m21s) You can do that also with folders as well as with files.
### Need To Set The Target Path And Relation To The Zip Package
[00:04:29](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m29s)
Then you need to still set the target path and relation to the ZIP package. You will have folders called admin. But as you can see here, I'm doing a folder called libraries/vdm_io. [00:04:45](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m45s) That means I am targeting a folder which isn't part of a component package. But because I want that folder to be installed with my component every time. I don't want to have a separate package for this library. [00:05:15](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m15s) I've improved JCB to include this package, which is, if you guys go look at this(see video) you will see that it's a composer file and I'm including some Composer Classes there, which we are now using in JCB. I'm moving it every time with each install [00:05:39](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m39s) into its place. That might be outside of convention I suppose, but there is neither rules against it. That's what we're doing.
Then you need to still set the target path and relation to the ZIP package. You will have folders called 'Admin'. But here I am doing a folder called 'libraries/vdm_io'. [00:04:45](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m45s) That means I am targeting a folder which is not part of a component package but because I want that folder to be installed with my component every time, I do not want to have a separate package for this library. [00:05:15](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m15s) JCB has been improved to include this package, which is, if you look at this(see video) will see that it is a composer file and I am including some Composer Classes there, which is now used in JCB. With each install it is moved into its place.[00:05:39](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m39s) That might be outside of convention, but there is neither rules against it.
### JCB Detects You Are Not Targeting Normal Folders - Add A Little Script To Script Install
[00:05:53](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m53s)
What's nice though is that when JCB detects that you are not targeting the normal Admin or Media [00:06:02](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m02s) or Site Folder, those are the normal folders. If JCB detects you're going to be moving content into a folder that's not part of the expected component package folders, [00:06:28](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m28s) it will add a little script to the script install. So that it all move this folder into its correct place upon installation of the component or whether the component is updated. You can go look at that. In fact I can show you just briefly. I have the component open, the script file for Component Builder. I'm going to scroll down. It's obviously a huge file. [00:06:58](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m58s) At the bottom we know have this new little script. Its named a little weird,(setDynamicF0ld3rs) it doesn't conflict with any other method at anytime. It gets the details from the above methods. Then it checks whether the folders gets the dynamic install folder. It checks whether there is more than one. Then [00:07:29](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m29s) if it's one of these media, admin, site, it ignores it, because those already being deal dealt with by Joomla. If it isn't, it moves it into its correct place. This is a dangerous feature, as you can see here I'm saying you must use this with caution. Because you can literally grab with this new function, anything anywhere from your Joomla website and overwrite [00:07:59](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m59s) it anywhere on the users installation website, which could be problematic. Something you shouldn't do unless it is your right to do so.
When JCB detects that you are not targeting the normal Admin, Media or Site Folders,nwhich is not part of the expected component package folders, it will add a little script to the script install.[00:06:28](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m28s) So that it move this folder into its correct place upon installation of the component or whether the component is updated. I have the script file for Component Builder open and I am going to scroll down. [00:06:58](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m58s) This new little script is way at the bottom ,(setDynamicF0ld3rs) it does not conflict with any other method at anytime. It gets the details from the above methods. Then it checks whether the folders gets the dynamic install folder. It checks whether there is more than one. Then [00:07:29](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m29s) if it is one of these Media, Admin,or Site, it ignores it, because those already being dealt with by Joomla. If it is not, it moves it into its correct place. This is a dangerous feature, you must use this with caution because you can literally grab with this new function, anything anywhere from your Joomla website and overwrite it anywhere on the users installation website, which could be problematic.[00:07:59](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m59s) Something you should not do unless it is your right to do so. >>>>>>>>>>>>>>>>>>>>>
This is the new feature in doing dynamic movement of folders [00:08:25](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m25s) and files. What's make this all so nice if you're using these constants in your naming of your paths, and you export and import this component into another Joomla website. I mean as a JCB package. If you export a JCB package and you import it at another JCB install, it remaps these files. It export them, remaps them and move them back into place on the other install. Which really makes it very comfortable in working in a team and you want to have these [00:09:06](https://www.youtube.com/watch?v=_c7wzW075lA&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m06s) files always to be the same everywhere. This is going to be very helpful for that.