From 7aaafa39813d540f9f6071d3f4b98e9864fb1092 Mon Sep 17 00:00:00 2001 From: Joseph Geller Date: Fri, 23 Nov 2018 12:40:17 -0600 Subject: [PATCH] Created Advanced Fields (markdown) --- Advanced-Fields.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Advanced-Fields.md diff --git a/Advanced-Fields.md b/Advanced-Fields.md new file mode 100644 index 0000000..7ad30bc --- /dev/null +++ b/Advanced-Fields.md @@ -0,0 +1 @@ +Hi we just finished with admin views and we now would like to start Cooking at advanced fuel types now there are a few advanced fuel types and the one there Is most advanced is the one called custom field type so I'm gonna sort this Here by custom Fields it's that one And you see it in This moment we have quite a few custom fields in place Now let's look at two of those one of the local file this List the other one is let's do a sermon sermon one but let's first look Look at the local finalist you'd see that basically from there All the way down to there is simply PHP So I'm creating a view which is most basically Taking information if you know PHP from the global settings of your component so there Any to be a field with a name local folder in your Global settings will still look at how to set up Global settings when we get to component and if it hasn't got a Setting it falls back onto the image which is in the J bus route For your component this will be replaced with your component name and it puts it into local folder And then I just start the options and I The options are a witches Fortune gonna return and the first thing I said to her there's a Please select a File add files Depot yes if there isn't files It will say please add files to and I'll give the local father's name if they There is files it work we gonna update those then over here so firstly we bringing File system classes from Joomla then we Basically check whether that folder exists and if it doesn't exist we created That's just in the fuel pipe now once it's created and if it Just skips this doesn't go in there and it just starts by grabbing all the files And from that folder and place it into files and then starts up an array Where is Loops the files inputted into options and By doing that we are basically images check you insure You're adding the file name and the file name To our options and then returning the options array so you can add your own custom PHP Scripting in the when you extend a listview so the list sorry list field were Extending list field so it's just gonna be a drop down list of all the files in that specific folder Hi there images or the for that it was set be overly in local folder ok so that's your setting up Although now there is a a a field Called filelist I thank Ya that is the reason why I didn't Use filelist is because finalist has a static directory to where You need to add the files so that you can view them and we wanted To have it be able to rename the file folder sorry for the For the files for the media do anything and then have it update itself automatically so that's why we didn't Custom field where we extended the list and we just refreshed this Detailed back so we chose a custom field and then We just extend the list type and we don't want to to have a at You button because you it won't work you will just break and we don't want them to select Multiple ways we are allowing them to select multiple now since we are using multiple We need to go back and make sure that we are storing it as a data so that Jason is when Multiple or erase any kind of arrays in a value you need to store it it's AJ And the opponent builder itself will check if it is a multiple Selection is true it will automatically store it in a Jason object even if you forgot to select this So we have got some things in place to sort of insure that it's system Behaves as expected Ok let me see that Susie quick view on Doing a local file custom field has a local file now Which I'm sure you all if you've been waiting for is let's look at how How to create a sermon preacher custom field so basically it's a Preacher So what is this field gonna do it's gonna show a list of preachers But is gonna basically display the preachers that are set up in the preacher listview ok so Open that so let's see the convention Is that you would call that type preachers that's the listview name But you'd called the name you would use the same as the editing Name which is preacher without the s so if you go back to your app and views you would Use this name as the name of the field but you would use that name as the type You see because you now creating a custom type and the logic behind it is it it's gonna show A list of preachers but you gonna select just one preacher ok so that's just the logic the labour You can really put whatever you like whatever is descriptive enough for your user to understand And then there's a place for adding a description then here we are set Multiple Tiff files we want them to only be able to select one preacher at a time E-40 all basically left to their default values and Extending list is the most common custom field that we have if you wanna See the list of custom Fields that is available you can go up here to extend and you see that list Radio and chicks check boxes are available I think I should update that too also say you User is also a user option to extend user If you want to see if we are what is available then look at that name J form field and go to component builder go to the Backing of component that would be administrator components component Then go to compiler that's a folder then go to Gmail at 3 Which is the current version we are targeting and then search for that J&J form there is a form so Ones that are available to extend the user J form field user you must it must say to a form field Sojay form field user game for field radio form field list Enjoy form field checkboxes this also means if there is a form field you why Want to extend that doesn't exist already in our advanced Seminar will show you how to add your own form Fields here there sit basically two places Change I wish I could tell you now one of them would be to add the field and update it accordingly And the other one would be too to add it in a few places in the code And also in a Jason file called settings there so does our Some of the things we will deal with an advanced adaptation of component Builder We will still set up that series very soon it's not finished yet though ok Getting back to extending a listview sorry listview you but Simply the Their list ok then there's also a few Conventions one of them being that if you are gonna be targeting like this Example we have Talking targeting the preachers you will be using the preacher Table as the table that is being targeted so the question to ask Is where is the data gonna be found that is the table That needs to be added in which component is it gonna be found and that is what need to be added by Buy component now the reason why we have this hush hush hush component here Because it's a placeholder which component builder will replace with the component score Once it's built it's a It's a Preacher we add it because some We want to rename components and if you had statically added The actual component name there then you have to and every field go and update that name and every Review go and update that name and you know every where were you with actually study the added the component You will need to update it but to explain to you exactly what the system Is doing I can go to components open sermon distributor And then take the name and code like that copy And see that it's on the on this course see if it was an upper Underscore lowercase to uppercase like that it mean It would mean that you have to place this the the component Name as well with an uppercase so you wet just do a scissor lowercase S lowercase so that is actually what the system is doing it actually is Just replacing these these Place holders with the with the actual component name on Fly so using the placeholders basically saves you time in the long run Prompt making changes everywhere if you make her change the components name Which is quite normal to do very often you start with the component in his think of calling it so I'm Realised that name is actually been used in the gym repository and you need to choose another And to do that is gonna affect the whole component and so we added this Placeholder structure which would make a better less painful at least man anyway Wherein all the code custom coding that you're adding and you need to use the components name You can simply use this hashtag format of replacement In some areas you would need to use brackets like that But most of the time it will use either way work either way the best Measure to ensure is to try it with a hash is first and If you go into the code and you see it didn't replace it then you know it's the angle brackets that needs to To be used anywhere so in this case we are using these hash The Hash signs Zimbabwe directors and then the view again that is this Single variable after view so if we were to close this and go to the view Which would be then preacher or lowercase Is what you would be adding here make sure that it's always lowercase And then the listview or the views plural with be there Add value there or lowercase as well and then the value field Is the field that the user will see so that is what is visible Full in the UI user interface the key field is the Value that will be stored in the database now these field relate to this table so in Inside the stable what field do you want the user to see now that would be the name of the And inside the stable What field would you want to store In the other database because we are looking into preacher but we gonna store it Wherever this field is being used right so that would be the ID and The column name in that data base of that view wethersfield will be used will be called Preacher so to show that to you in the database itself can open it there Scroll down to summon distributor open sermons Kickoff structure and here in the back end It's closed this go to Sermons new And will see that there is a place for preacher If I was to look with firebug and it we'll see that it is basically The name is preacher and remember we spoke about this day on this day fall on the score as the ID But it's actually Simply the preacher field which is being stored directly in In the database in the preacher Column of the table and it's stored as integer 11 and that It was set up here right in the chair 11 and we say that it is a key so we can Target So here at the bottom if we looked at in Nexus will see that it Has actually added it is a key and we go ok so that All is done right here in the database structure and then in this area Nog n in the this part which you can add your own custom PHP The fact that I'm using 1918 17 is just sort of creating Line breaks and spacing and tabs for me dynamically I could have placed them All just under PHP one with without this Quotation marks Uno Wrapping around the mall like we just did with the file file folder list View Previously just a note inside of this code you cannot These a quotation marks you need to Use single quotes unfortunately at this stage it is not able to Comedy or if you even if you try to do an Escape it will not behave as it's as you So my apologies for that at this stage you can only do single Quotes between these two quotations and I will quotes Ok so that is adding a custom field which is that made more at bomb If you know PHP your know exactly what's happening here again these Place holders Flat back to these values here so basically a dart ID will be written there Text value the field value is gonna be called a dart Name and then ID and code text this code Is build-up by the view that we are in and the text so this would read Preacher sorry sermon preacher in in in the code and that I can go show you how it looks when it builds it it's quickly look at that So to show you where it starts let's open that Field list to this is what it starts with basically it replaces this place holder With your code ok and it replaces all these features Up here as well And updates that and So every where you see these things It's gonna be updated And obviously everything up here will be replaced with your licensing Ok so that's look at that But then now let's look at the Finished product Sermon Based on the modules field There's pictures Open it You see that it added preacher there And in the input Did add it and it also shows you Where is you have trip that's what's like me Plane to show the line-up It shows you in what file These files I found Under The If you got two components on the compile sorry no Under helpers Compiler We are these files Being used While I'll possibly when we go to the advanced section I'll go much more in-depth Regards to These files Now we just trying to get the cross how to build a component Not to extend Builder itself as yet But at least you're you can see where in the code it is actually building this Piling listen Putting it together And Remember we talked about It is Getting The structure let's Go down I guess this is Used for the button This is to generate a new Batman When you are when you when you Can click on new Basically that is Button there There is generating the button This is what controls whether the button should show up aware that it shouldn't then And even if it is to be set at all Ok so this is basically what generates the button This area here the gate options You see we said that it will show the name And it will show ID And so Go back to our Structure here It basically we dynamically replaces these with those The reason for it is it's actually done a few times And I felt like ok let's let's make it that you need to update these values And then if you get update gets updated all over it Bottom of the code And it makes it just much more easy to To change your custom Fields Sorry Build a field called preacher name Which again it uses Because it Retrieve the object From the database Nsfl objects Cysts Accelerated And builds up Auction list Returned So dynamically generates your list It's a component builder through that infrastructure that it Just explained here Actually compiles all of that code for you And puts it in the right file in the right place and all of that And obviously once you build a component and you know where you have made those changes in Builder You can go look at those files If you know how to build a Joomla website I use the same conventions as decor In regards to implementation Of your files Ok At the moment we are only pulling values that are published This is what that is That is the custom fee I feel like I am Maybe Mumbling on without purpose so let's get out of this one I think we can quickly look At this One which Dropbox This one is much more advanced What we are dealing with here Is a file That actually Is stored if I look here in it What I did is I created a function in my component Global helper function Called get Dropbox links Adele's in that it Once manual links And it bad to say Specific Variable 2 And it would return a bunch of links And those links it will check if it exists Check the array not only that it is an array but it actually has values in it And if it does it actually just back City Options And gives it Over 2 The options are Now This part here Means that you can in your Custom field types You can add a helper Static Method call If you know what those two symbols near me It means it's a static method Being called from a From a class Now this class is something that if you're a No did you lie API and know how to work builder component You know that You can add to any component what is known as a Helper class Now If I was to go to summon distributor The component helper class is always Located In The helper Folder The admin as well as the site View The admin is then in the backend which Administrative components And then There is the component And there is it's helper Folder And the front and you have the same convention Ponant 7 Pewter And there is the helper Structure Ok and here is some of the Scripted Components sorry which cement distributor structure Through it's helper structure There is the Helper file for the front And here View helper file For the back How to add methods Do they already Helper files Have you don't want to know what all the custard helper is is That we ship With all components You can open component Builder You can go to the compiler Sorry Go to gym at 3 And I look for the helper file in the site help If you open it You see alot of helper methods obviously with a lot of Place holders Which we will Customised for each Component Targets that component And you see there's a Jason tostring method here to say get bars Music bar singular This is just to get one variable from the database we don't need to always Reese Books right This whole string To get just one variable You can actually come and Look at how this works and use this To get a variable from the database We also have is published Check if a Specific Object is placed I get actions But again This is way beyond the scope of Just looking at custom Fields We will go into great depth into all the features of a helper structures in That when we deal with advanced concepts But I'm just giving you a heads up so at least you can start looking at it and Possibly get yourself going We are I wrote these Functions check object check array check string I take Jason Shorten Merge arrays Save string And Escape HTML Replace numbers this one I'm using White orphan You know if you basically do Save string We change every number in the string or immediately to Do Text So that you can be sure whatever you get back from safe string Doesn't have numbers in This is sometimes quite necessary in fact All the time Especially if you don't know if there might be a number that the First Character Mike Pienaar This way we are insulin that Always It's actually text Ok so there is just a whole bunch of Custom Methods that we ship With all components that are developed so if you were to Open Like I said Swimming Distributors Custom Sorry Helper Glass You see that these helper classes are now Showing up here Directions Shorten string major a She can come and if you are any of you feel that the methods that I have to use theories arcade or Outdated Please go on the forums that get up and talk with me about it All very gladly look at it C I know I recently tried to improve on this chicks String By doing That So I could actually dump The spot Save on Query But For some strange reason This started Causing problems All over and strings that were strings were being returned does not beings Tightening But what I can tell you is that Hi Obviously Went back to the old School way of doing it This way I don't know That there might be an easier way Obviously we first one to ensure That it's set That actually This value is set And then it is string and then it actually has a link this is something can be a string and yet don't don't have a length I might be wrong on that and yet this is what I found I've only been coding and PSP for 3 years now so I'm definitely You get teach me a few things You been hurt Ok Back to the UI That is where I get these values so showing it to you In here Go up a bit Says get Dropbox links C Now We see that Does this thing of return Which is set to false Now that means if I only was to say That it should return the manual Values Then it will only return the value manual links But since I've said it 2 It will actually return all of those links and not just One of Ok so because you can actually target that it returns One specific sermons So this method is Squat dynamic And that's all that I'm calling In in this Advanced Fuel type Which is called custom field And it gives me a link of all the Sorry an array of all the Which I did just load like her Ok so that is again as you can see quite Advanced implementation of this Custom fields And Obviously As you Hope you would realise Siri can do anything You can with that list conception You could even grab a bunch of website names You can put any PHP in there and build a list which can be used To save to the database Ok let's see that would be the custom Custom Fields there is also one called custom user How to custom user at the moment it doesn't look like I have any The demo There for you So I just click on you And then select Custom user And You see that the custom user basically You don't need to set or changed Change anything From Here to there All days should actually just work Departed you might want to consider removing Would be The BHP The spot Basically what this part does Is it limits the The user list Do only a certain Group That means again you need to set up a global Value in your component Field In your Global About that Basically the options button Clip-on options Open set Place which you said Global these are all Global values this is a Area for Global Values Now You can get hold of those Global values through the component helper Get params with a component Name And get When there you would paste So that's how you can get a value from your Global settings And basically I'm getting a specific Groups value and place again in here And then I am Returning that group that's all this part of doing Impact Does two sections are actually So this one Is what helps you Set Ok I wanna just return a specific group Disbarred Help Sue Set Any users you want to X Now this specific feature here Ensure that only one record per user is set so let's say a user has already been Added to a previous record Then That user should not show up again It should be removed from the list So this is what this PHP is doing It's simply looking to this current View And checking if the If there is users and getting their ID is in And then setting them Up in the correct manner They are unique And then returns them So Those are the users that already have So if you are building something Which are supposed to To have Student ID details for example You don't want a Student to have one than more more than one Entry in that table right You want every student to just have one in And so if a student already is selected You wouldn't want them to be selected again that's what this Exclude feature Act How to show that to you in the code Let's go to Another project that I am Working on for learning manager And they have Field Court student Student uses Now There are two kinds of Ways to To do this One is to a knot Allow more than one user To have an entry And then you would basically The one is saying ok exclude users that already have been used So that means if you use it been selected that whole thing that I've just explained The other one Ashley returns null which means it will always show all users And the way to have it set this to lol Would be simply to remove That part Of your Of the code Then it will automatically set This value to null Now when I gets about the group part it's the same principle If you don't want it to just show a specific group You can actually it will also be set to now That And presumably component builder will do that And all you need to do is simply remove What is part of the code And then it will actually And so That is true Target a specific group And also to Target Or to remove specific users So let's say That You want to remove users that Belongs to other Table or other structure then all that PHP that you need to write You can place on the day Type Php.exe So you could do That Die PHP x 1 = All your PHP can be placed 44 excluding And For the group It's simply Sorry not Directly one You can just Take that And This one will be used For the groups that actually says it there Get exclude method PHP for the gate group And in the code Which is stored under Fields models You see what it will do so you can do things and then come and look What did component builder build How does it Login Then you can actually go to the view Mike we have here And see does it's actually work is the preachers showing up And then you can use firebug That And you can look ok so That one is Index Here is a select list And here you have the values So that's the ID And that is the actual name Eid and then So that is how it should Display the data in Component Builder Set up the XML structure that Joomla uses This is this July Building this whole structure For you So even this nice button and everything Accident handiwork It is doing that For you And This is all done through these XML Input values that So you were changed it type 2 You might say stuff Oh yes there is something to To remember here The type names May not have on the scores Or any spaces in them Fact anything that is not translatable Usually needs to be 0 Not not have any underscores Sorry not have any spaces So you can't do this That would it will just not work So you must Remove the underscore You can do that but that's Sort of Think it will be made lowercase anyway So you could just And then it will work because that is used not only Indiphile Database but it's also used in Everywhere this file type So as you can see In here That file type is called student And even the file is Hope that And here it is Student user and here it is called student user And this one Yes in the file server So you can see that that that specific name type Name Is used everywhere And you cannot have underscores In this class name Neither in this tire type name You know maybe you can but So far my experience is that it doesn't work If you do Have it So for some reason it It doesn't work So that's just a heads up on Naming of this type And so you can update these Fields they are mostly Feels that are Sort of Related Do all the other fields But this one specifically says extends user Ok so it actually Shows you how it's gonna extended So if you removed all the PHP then this field as it is now Which show all users Ok Close out here That is looking at the advanced fuel type called User Custom user Another one we need to look at is the repeatable fields Repeat of fuels is actually not that difficult But you need to understand how it's sort of structure You need to first create the fields that you want to repeat Inside of repeatable The way repeatable field structure looks In July I mean When you look at it Natural application See where Ok here we have one So this from there On the way to there is one repeatable field And If you know a little XML and you worked with her beatable Fields you'll see that Here is the The fields that are being repeated Inside Repeatable So basically repeatable field is a field type that has Other Fields inside of it Now you don't need to write any of this The way you would Structure a repeatable Fields actually Very very SIM You first create the fields that you want to Repeat And do realise you can't use repeatable fields in repeatable But you can use custom advanced fields in repeatable So if you look at that We have your again You see there is a fuel type called calls at risks Now you if you know You know there is no such field type cause and risks So that means this is a custom field so if I were to go to fields You see that there is a field called here cause Cause and risks And it basically Get set information From From this database table This is another component Drive down with And it Is Displaying Load data also making some model changes And adding some Some style to it Breaking space That is that is just dealing with Cause and risks So looking again at our repeatable field You're able to add an advance custard Inside of it But what you need To add it Is let's Open Females Flower example As you need to have the field ID And you need to order it according to Order Rwanda displayed in the Line Where you do repeatable fields So if we If we close Go back to Creating a new admin view and I click on field You see that there is 1 2 3 4 5 6 7 8 9 10 11 12 13 Fields Enviro And if I click next and they all appear again And if I click next they all appear again And that's what repeatable Fields really is about Now just structure these Fields if we Would you look at it how did I develop The specific Pop-up Repeatable Structure well I can show that to you Here is a list of all the repeatable fields that I've already built List three pages of 20 If we were to click on at Files You were looking Feels that Harris Hatfield for views Open that So this is the repeatable field for adding fields for Views And all you see here is I'm saying ok you could add 800 fields But ok And we call him the button Add So if we go back to Review See it says add And then I'm adding an ID in a class to it A description with if we were to hammer over it Here It has a little setup feels for this view Which is the description Same there And the label is fields So Airfields And Then the icon is list Audi icon Is what is shown in the button That is a list All the custom Joomla icons R You can can be used How to know these icons you should go to let me see There is a URL Darkx.com mob.org Forward slash J3 dot x jumla standard icon Farm That is the URL And you'll get to this page And These are all the available icons And you basically use that Apart This part So I wanted to check Mark Circle Check Mark Circle And I would In here Simply The icon Change that to Check Mark Circle Ok So that's how you change the icon And then these are Simply the ID is Of the fields I want Inside of the repeatable Ok And so if I was to Show you where to get the ID It simply would be close close your Repeatable field And you'd see the ID is next to the fields there on the right So you would create it The the Repeatable field statues The fields that you wanna use in the repeatable field And you would get a list of those ID drop it down so maybe somewhere and no pants on Just add them in the In the order that you want them to be Added And then inside of your repeatable field Are you a simply Pasted in the fields Area with a comma separator And then do a component builder will Dynamically Construct this whole structure For you And add it To your Component I think it's really Stunning and I hope you enjoy using Repeatable Structure I know it's little buggy still and there's a lot of talk about it not being as Stable But you're more normal basic Fields like text Fields and radio Buttons and so forth they all work Well not the only thing about the radio buttons that use that you use in Henna In a repeatable fields You need to remove the class Of your radio button So It cannot be a button It must be a dot Unfortunately it still they don't Yet make it She like the button What's the difference Well That is the button Virgin Of a radio button Gate And That is the Dot version Of the radio button And it doesn't look like a button And so in your repeatable Fields you cannot use the button It needs to be this one And what makes it a button is obviously the class That is Being added to the field So you need to remove the class Very Values From your radio button If it's gonna be Repeatable But anyway if you forgot To do that and you compile your car Opponent And now you looking at the repeatable field you'll see that the radio button is You know that it's not working Messed up Until they possibly fix it Unfortunately Ok that is looking at advanced field Corey fields Gold custom Fields custom user fields As well as repeatable fields These are really the advanced field types that there are The other thing that I wanted briefly mentioned to be so how long if we already been At this Ok see this is getting a little long So Let's move What I wanted to share to a later topic Thank you for watching \ No newline at end of file