-
-
Notifications
You must be signed in to change notification settings - Fork 178
055 Dynamic File and Folder Inclusion concept
I would like to Introduce you to a feature that we've been working on for quite some time now And I'm very sure it will Come as a surprise to some of you that actually can do this Most of the features already existed For quite a while It's just that I've been Trying to make it Stable so that It will work well And in doing so I had to extend it a bit So I wanna I wanna look at this feature It actually has three Two or three concepts which maybe is best if I explain that So what is this all about Ok It's about adding Dynamic Files Folders Or even external Files Which maybe is on a website Or On GitHub And you want to Get the content from a file and add it Maybe is code Or even as a file To your Fuel system So Here's the thing I'm working with components that is pulling data from all over the place And so Most of these features are really what what I've been needing to Get projects going And Trying to save myself Time That I don't need to Copy paste and move things around to ensure that it's a correct copy being used and on compilation Andre CB itself is maybe one of the best Explanations So let's look at this You know that there is a feature But you can add files And folders This feature is like I said it's always been there But currently Afrix penitus By adding an advanced tab to this feature It's got this basic which is the normal one Which if you watched some of the previous tutorials the auditor Orioles I do actually explain How this works And how you get these files and I'm not gonna go into that There is now a new area called advance Sorry I had to just quickly update that note for us Advanced area now Is able to Grab Files from anywhere in your system An added to the component Now It can be files outside of the root Directory of your Joomla website Just being sure That The PHP Which usually is a patches permission Has the right to the file and can read it So this is just the only thing But for most cases We won't need to grab files outside of the Joomla root directory because we actually Maybe just editing a custom script Custom file Inside of a G Muller Component which we've created But this file or This folders are not Generated by JCB So we want those files Weather actively running inside of a component We want them to be Basically taken and put into the package without us having to move it around That's what this featuring will now do So you can like a I'm doing here I you can use constants You'll see there's a little note here that tells you that That you can use Crossing paths and the full path Directly without quotes that means You don't need to do You know like in PHP here are you do something like that wait no not And you put this part in quotes right like that What are you doing need to do any of that You put the constant directly Like that and The compiler will deal with this And make it right So That you can do also with folders as well as with files And then You obviously need to still set the target path and relation To the ZIP package So you have folders Called admin But as you can see here I'm actually doing A folder called libraries And That means I am targeting a A folder which isn't actually Usually part of a package I know a component package But because I want that folder to be installed with my component every time And I don't want to to to actually have a separate A package for For this library I've actually Improved JCB to include this Package Which is basically if you guys go look at this You see that is It's basically a cop Composer A file and I'm including some Composer Class is there which we are now using in JCB And I'm moving it Every time with each install Into its place Now That might be Outside of convention I suppose But there is no the rules against it I think in Yeah so That's what we doing What's nice though is that when JCB detects that you are not targeting the normal atman Or Media Or Image folder site Those are there did normal folders Then Await not Imagefal is neither is that normal But did you got your see that site admin and Media If If Jason be detected your Gonna be moving content Into a folder that some part of the Expected package component package folders It will actually had a little script Do the script install So that it all move this folder into its correct place On upon installation of the component Or whether the component is updated So you can go look at that In fact I can show you just briefly So Europe got the component open The Script file for component Builder Scroll down for this huge file But here at the bottom when I have this new little script It's great name the little weird so it doesn't conflict with any other method in it at anytime And basically It gets the The details from the above methods And then it checks whether The folders obviously it gets there the day that I have the namak install folder It takes whether there is more than one And Then If it's One of these it ignores it because those already being deal dealt with by Jace And if it isn't It actually moved it into it's correct place Now this is a dangerous featuring As you can see here I'm saying you must use this with caution because you can literally Grab With this new function Any Thing anywhere from your Joomla website and overwrite It anywhere On the Users installation website Which could be problematic And Something you shouldn't do Unless you are I know that I listen to all right to do so Ok so this is the new feature in in doing dynamic Movement of folders 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 Then I mean as a JCB packets right If you export a JCB package and you imported at another JCB install It actually remaps these files it actually export them Remaps them and move them back into place on the other install Which Really makes it very comfortable in you in a working in a team and you wanna have these Is files always be the same everywhere This is so gonna be very helpful for that I can also Obviously because of the feature I give you the heads Up But if you import a package From anyone And and you do not know or you do not trust them Record actually move files Through this method into your system And is therefore part of first security which you need to consider With whom you are sharing packages Anyway So this is so some of the Feature regarding the new folder in Plantation folder in 5 of limitation Yeah that aspect which I mentioned earlier Were you actually able to get content from anywhere Works as follow So anywhere in any custom area of JCB Where you can actually add custom script You can also now used to this external code Snippet Now this could be a URL Or it could be a folder inside of your system This folder does not yet work with With Constance I should actually make it that it does And it actually needs to be the exact for the path of the stage But the reality is that with this external code Concept You can take For example Ballet variable From a Gets snippet let me let me show you We here I have what Is it called fancy date Which is basically a few functions static functions Which are not wrapped in the class yet so it's basically outside of a class And why because I want to include it Into my Helper class With the snippet So That I can have others work with me on this code on GitHub And If any changes be made to this code it automatically updates my system The I know that there is some question of security and doing so But with added a few little Tricks in the compiler The actually notify you If there's been a change to the code So what that means is the first time you use that snippet To include this snap Leopard that you've got here You obviously do something like Raw And then here I have basically a text file So you'd grab that you're all An added like this You can take away The actual because currently It is bound to a specific version Which obviously If anybody makes it changed to the snippet You won't get the new version Well that's the way of locking it in But if you wanted to have it be Dynamic you can actually remove a part of this I think it's this part Let me just check Yeah that's right Then you can use it like that Now this pacific's piece of text that you see here Will dynamically be added to my component Let me demonstrate So you arrive open component Builder And it's back end I'm gonna scroll that I've gone to this lips and helpers tab I'm gonna scroll down To this area which is called Admin class so I'll just do in the admin area so that's easily Detectable I'm gonna add that slip it like that so it says external code With the path of the euro And That's it I'm gonna save and close Then let's go to the compiler Now what should happen Is that the moment you've compiled this it should tell you That you've added This kind of external code to your component If it doesn't tell you that then something's wrong it should tell you the first time you and the snippet Because it actually creates a hash Off that snippet So that in the future if it changes You get notified So when we grab the snippet from Get help Nne worry in the middle you know Tempest with it It will notify you that the snip it was changed now if you know that it should have changed because You made a change to the gates Uno snippet or someone else in your team did That obviously you'll be expecting that But you could still for safety sake go check in the code of the component Where the snip it is being added to ensure that it is actually still accurate So I'll show you that Let's compile this So we see two messages that are relevant to the issue at hand This one is a new message which I'm not gonna go into now But it's basically dealing with that That is actually detected That Remember we said we have this folder we Putting inside of the Library folders And Everytime You compile You actually tell you that You tell you That it is detected it and it's added The Script to the script PHP So I said I was gonna explain it I did Anyway so that's what that is about but this first line here Is showing you the snippet And it's telling you there's been at it for the first time And that you should be investigating so the correct code string was used So you should go To the place where in JCB the Surrey in the package The compile package where this would have been added Go and check that it is the correct That what you see here on get up The string here Is also what you gonna see in the code That's the first thing Every time there after it should give you this little message here And it should tell you how many coach strings are being added to this component as an external code Anti voice sipping your component with malicious code string always make sure that the correct code string values Were used I did tell you that if we did take the change it will also notify you so First let's go do what it said here Let's go check that it is to correct code Cuz I won I'm in the ZIP package So we see here that's why I like the library folder it being added Yeah we gonna go to the admin area helpers and then open Component Builders helper File which is where I added the snip it right Just open that And then Here we have it Glow fancy date And fancy datetime So Basically from here To hear Was taken from get up and put inside of the component Now I'm gonna go make it change to the snippet I'll get up I'm gonna just do something small So that we can see what happens if it change is made To this code And how Jason B response I'm just adding this New little string here saying trains was made And I'm updating this public Guest So it now tells us that it's been revised for a second time And a change was made Now let's compile the component without doing anything else just make the trains here and get up Then go back to the component and compile it Sorry we are Selecting version Compile I can see how have the maybe add some space in between the messages here Doesn't always seem clear enough That the messages are not related to each other like Here it's showing that other message again like it said it would But you might miss that So I think I'll have to look at that anyway Here in the warnings area We see this We see that It has changed Since the last compilation Please investigate To ensure that changes safe That means JCB is automatically detected That the snippet that you originally had it has actually been updated At this point we anticipated that so If we go and look at the code We see that it just added this little party or change was made And the rest of it is exactly the way we want that And so everything is fine It's a change we anticipated So we know that nobody else has tampered with the script And neither was there a man in the middle attack An in any case If there is someone tampering with the script It will end up as a string here So they say they'd put something in here for Will do Something like that whatever they put in And you will see this error In your file So that's Basically how it will work no play out But in the actual reality Jason he will detect that It will see that the hash for the script is changed And it will notify you with that message I'm gonna do my part and trying to make sure that it's more obvious you won't miss that message But that anyway when you use this kind of implementation It is not the most ideal implementation it's just that sometimes we wanna include index Sternal value in R component Which is the name changing And Wanna do it without really thinking about her time And this is what this feature is ideal for I'm so use it with caution and You know know what you're doing Or don't use it at all So that was a quick overview Of the new Folder file Inclusion As well Ext external code Inclusion Features which I really trust would be useful to you It's powerful tools so I realise They are the danger of it being abused But at the same time I think component development works upon reputation and if you wanna have a good trip Station in the community You shouldn't do anything that will hurt others Or damage there Contribution And their applications What is a steer Within the parameters of your own component And your own implementation and any case because people are gonna look at your code they are gonna answer Zip your package they are gonna see If you're doing things that are not You no good they're gonna notice that and your reputation will get hurt And that's the last thing you would want When you're developing components for Joomla Anyway thank you for watching
- Home
- Beta Testing
- Custom Code
- PHP Settings
- Demo Component
-
Tutorials
- Hello World JCB
- Intro JCB Guide
- JCB Installation Steps
- Planning Components
- Field Type Overview
- Basic Fields Creation
- Admin View Management
- Advanced Field Usage
- Admin Component Integration
- Component Setting Customization
- Scripting Components
- Component FTP Options
- Dynamic Get Method
- Site View DynamicGet
- Site View Templates
- Template Setup Guide
- Layout Configuration Steps
- Custom Admin Management
- Adding Site Views
- Custom Admin Integration
- MySQL Demo Tweaking
- Global JCB Settings
- Custom Time Field
- User Helper Integration
- Email Helper Usage
- Message Store Email
- List View Unescape
- Export Import Customization
- Overwrite Custom Fields
- List Field Filtering
- Automatic Code Import
- Manual Code Implementation
- Component Export Import
- Custom Admin Buttons
- Translation Management
- Site View Permissions
- Component SQL Updates
- Site Edit Configuration
- JCB Backup System
- Helper Structure Integration
- JCB v2.5 Upgrade
- Tab Setup Guide
- JCB v2.6 Release
- Extended HelloWorld
- Field Rule Validation
- Community Snippets Intro
- Snippet Forking Tutorial
- Pull Request Snippets
- Library Manager Area
- Excel-based Translation
- Dynamic Router Details
- Database Auto Updates
- Subform Quick Demo
- VDM Package Import
- Dynamic File Inclusion
- File Field Upload
- Drag-n-Drop Upload
- Quick HelloWorld JCB
- Non-database Fields
- Dashboard Customization
- Menu Prefix Toggle
- Community JCB Packages
- Collaborative JCB Workflow
- JCB Package Install
- JCB JAB18 Event
- Convenient New Fields
- Component Language Strings
- Library Functionality Anticipation
- Join Field Relations
- License Template Change
- Code Reusability
- Local Dev Environment
- Extended Field Types
- Joomla Custom Fields
- Custom Field Expansion
- Site View Listing
- Run Expansion Method
- Form Site View
- Field URL Update
- Additional Helper Methods
- Field Validation Rules
- New Placeholder Feature
- Component Config Params
- Per-field Default Values