Updated 032 JCB manual custom code implementation (markdown)

Amigo 2019-08-15 14:20:59 +02:00
parent 5593c269cb
commit 0a7098b050

@ -6,19 +6,19 @@
(_Click on these time links to see Youtube video_) (_Click on these time links to see Youtube video_)
Automatic import of custom code during compilation. This is one of the latest features that has been added to the JCB component. Although all its functionality is in place there is currently some limitations which exist that need to be explained. First, what does it accomplish? It actually mutated from that which its original purpose had been and became two things.[00:00:52](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m52s) The first thing is, (and this is obviously what was initially intended) that it will be possible to add code to the component once it has been compiled and installed into that same Joomla website, then to be able to go into that code, with a few placeholders add code, that once the component is compiled again, JCB would dynamically grab that code, extract it into its database, store it there and from there on forward continue to add it back into the component every time. [00:01:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m43s)The way it have been done was that the line numbers had not been used as the main way of determining where that code must be added. The reality is that the line numbers will always change. It may be Custom code that is added, for instance line '105', and if it is made to change at line '20', that means all the code moves down of course and it is impossible to know where to add your code without either writing over or placing it before, there are all kinds of complications. So the only way to resolve that is to create what had been initially called the fingerprint, but later became a hash reference of the code, a few lines of code above the custom script, and a few lines of code below the customs. [00:02:50](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m50s) It varies from how many lines it uses. There is a reason for it. Automatic import of custom code during compilation. This is one of the latest features that has been added to the JCB component. Although all its functionality is in place there are currently some limitations which exist that need to be explained. First, what does it accomplish? It actually mutated from that which its original purpose had been and became two things.[00:00:52](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m52s) The first thing is, (and this is obviously what was initially intended) that it will be possible to add code to the component once it has been compiled and installed into that same Joomla website, then to be able to go into that code, with a few placeholders add code, that once the component is compiled again, JCB would dynamically grab that code, extract it into its database, store it there and from there on forward continue to add it back into the component every time. [00:01:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m43s)The way it has been done was that the line numbers had not been used as the main way of determining where that code must be added. The reality is that the line numbers will always change. It may be Custom code that is added, for instance, line '105', and if it is made to change at line '20', that means all the code moves down of course and it is impossible to know where to add your code without either writing over or placing it before, there are all kinds of complications. So the only way to resolve that is to create what had been initially called the fingerprint, but later became a hash reference of the code, a few lines of code above the custom script, and a few lines of code below the customs. [00:02:50](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m50s) It varies from how many lines it uses. There is a reason for it.
### Updating Code From JCB In The Editor ### Updating Code From JCB In The Editor
[00:03:01](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m01s) [00:03:01](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m01s)
If you want to see how it had been done, the code is open source, it is possible to go and look at it. There is a function in the 'Aget' file, which is part of the compiler a set of files. The functions name is 'searchfilecontent'. It's in this function that it really goes through every line of the code that is already on the Joomla website. When it finds it, it adds it to an array which eventually gets saved to the database. This is the lines that actually does the work. [00:03:53](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m53s) There's lots of things that works with this function, but this is the center of everything. There are better ways to do this. It will constantly be improved and insured that it remains stable as suggestions is being made. [00:04:27](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m27s) It should never use more than 8 lines as it is here where it is packing the fingerprint and takes the line content and place it into an array. Every time it passes, it checks whether that array is greater than 10, and should be cut down to 6. [00:04:54](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m54s) This continues to happen over and over because this fingerprint array should not become bigger then 10 lines. At some point when a placeholder is found, the fingerprint array is taken, a hash gets created from it, then it is stored into the database. [00:05:24](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m24s) That means that amount of lines are changing. Because the array has been cleared and are at 6 lines. Then a 7th gets added and now we find a placeholder and everything happens. If you want to see how it had been done, the code is open-source, it is possible to go and look at it. There is a function in the 'Aget' file, which is part of the compiler a set of files. The functions name is 'searchfilecontent'. It's in this function that it really goes through every line of the code that is already in the Joomla website. When it finds it, it adds it to an array which eventually gets saved to the database. This is the lines that actually do the work. [00:03:53](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m53s) There are lots of things that work with this function, but this is the center of everything. There are better ways to do this. It will constantly be improved and insured that it remains stable as suggestions are being made. [00:04:27](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m27s) It should never use more than 8 lines as it is here where it is packing the fingerprint and takes the line content and place it into an array. Every time it passes, it checks whether that array is greater than 10, and should be cut down to 6. [00:04:54](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m54s) This continues to happen over and over because this fingerprint array should not become bigger than 10 lines. At some point when a placeholder is found, the fingerprint array is taken, a hash gets created from it, then it is stored into the database. [00:05:24](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m24s) That means that the number of lines is changing. Because the array has been cleared and is at 6 lines. Then a 7th gets added and now we find a placeholder and everything happens.
### Quick Explanation - Insert/Replace ### Quick Explanation - Insert/Replace
[00:05:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m43s) [00:05:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m43s)
There are two ways in which the code is added. It has been explained in the previous tutorial, and will be explained again. In that same file there is a comment way at the top, which gives the explanation of the placeholders. The placeholders, these X's here, must be asterisks. Like this one(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///). [00:06:26](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m26s) This is the one with which you would start either to insert or to replace. There are two ways in which the code is added. It has been explained in the previous tutorial and will be explained again. In that same file, there is a comment way at the top, which gives the explanation of the placeholders. The placeholders, these X's here, must be asterisks. Like this one(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///). [00:06:26](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m26s) This is the one with which you would start either to insert or to replace.
### GitHub Explanation For Update And Insert Issue 37 ### GitHub Explanation For Update And Insert Issue 37
@ -26,11 +26,11 @@ There are two ways in which the code is added. It has been explained in the prev
There is also a note on GitHub about this which may be more logical. It's on issue 37 under Joomla Component Builder on GitHub. Basically to start inserting code, this (///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) is used as a placeholder, then your code on a new line, then when finished, this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) would close that code block. There is also a note on GitHub about this which may be more logical. It's on issue 37 under Joomla Component Builder on GitHub. Basically to start inserting code, this (///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) is used as a placeholder, then your code on a new line, then when finished, this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) would close that code block.
Sometimes you do not want insert code, but want to replace code that was generated by JCB. Then the replace code placeholder(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) may be used and again use this one(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) to end the code block. [00:07:25](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m25s) Now when Component Builder on compilation discovers these tags(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///)(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///), they get converted to from insert to inserted and from replace to replaced. It adds it back without this diamond(<>) between those dollar signs and the inserted text or replaced text. [00:07:55](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m55s) It removes it by doing that, it means that this code does not need to be updated. The moment those two are added back between those 2 values, when Component Builder compiles. It interprets that this piece of code need to be checked again and update whatever is in the database, because it has been changed. [00:08:25](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m25s) This diamond here indicates it. There is a change that needs to be updated. There is this new number being added next to the code.[00:08:49](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m49s) That number is the ID of the database row in which JCB had stored the code in. If this number is changed, a problem will occur. NB. Do not change this number. JCB had placed this number in, in order to know where to go to update the code in the database.[00:09:18](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s) Once any changes had been made to the code, simply add this diamond(<>) back in, that's quite important otherwise it will not be be parsed, and it will be overwritten by the content in the database. Sometimes you do not want insert code, but want to replace code that was generated by JCB. Then the replace code placeholder(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) may be used and again use this one(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///) to end the code block. [00:07:25](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m25s) Now when Component Builder on compilation discovers these tags(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///)(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///), they get converted to from insert to inserted and from replace to replaced. It adds it back without this diamond(<>) between those dollar signs and the inserted text or replaced text. [00:07:55](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m55s) It removes it by doing that, it means that this code does not need to be updated. The moment those two are added back between those 2 values when Component Builder compiles. It interprets that this piece of code needs to be checked again and update whatever is in the database because it has been changed. [00:08:25](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m25s) This diamond here indicates it. There is a change that needs to be updated. There is this new number being added next to the code. [00:08:49](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m49s) That number is the ID of the database row in which JCB had stored the code in. If this number is changed, a problem will occur. NB. Do not change this number. JCB had placed this number in, in order to know where to go to update the code in the database.[00:09:18](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s) Once any changes had been made to the code, simply add this diamond(<>) back in, that's quite important otherwise it will not be be parsed, and it will be overwritten by the content in the database.
The initial purpose of this new feature had been to be able to, create code in the editor and then on the fly, make it part of the JCB infrastructure for your component. Then in the future it will continue adding that code back in without you having to write it, or to remember it.[00:09:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m47s) If it is necessary to change the code, just add these diamonds(<>) either for the insert or for the replace depending on what has been done. It will automatically update what is in the database, and then store it back into the new compiled version. The initial purpose of this new feature had been to be able to, create code in the editor and then on the fly, make it part of the JCB infrastructure for your component. Then in the future it will continue adding that code back in without you having to write it, or to remember it.[00:09:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m47s) If it is necessary to change the code, just add these diamonds(<>) either for the insert or for the replace depending on what has been done. It will automatically update what is in the database and then store it back into the newly compiled version.
[00:10:12](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m12s) It is a stunning new feature. There had been some challenges on its implementation. There is some comments to look at. We are at the moment at version 2.3.2 which is not yet released that will include the extra feature which have not been discussed on the forum. A ideal had been born to develop a very smart function, a custom script, inside of some view or some field or somewhere in JCB and to use it again elsewhere but then it have to be copied, and pasted and then improved. Then get this(See video) added and get it debugged, improve the whole function, maybe just pieces of script. Then it is a tedious task to copy it back from where it have been taken and then there is variables that need to be considered which need to have different names. [00:11:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s) [00:10:12](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m12s) It is a stunning new feature. There had been some challenges in its implementation. There are some comments to look at. We are at the moment at version 2.3.2 which is not yet released that will include the extra feature which has not been discussed on the forum. An ideal had been born to develop a very smart function, a custom script, inside of some view or some field or somewhere in JCB and to use it again elsewhere but then it has to be copied, and pasted and then improved. Then get this(See video) added and get it debugged, improve the whole function, maybe just pieces of script. Then it is a tedious task to copy it back from where it has been taken and then there are variables that need to be considered which need to have different names. [00:11:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s)
### Custom Codes In JCB ### Custom Codes In JCB
@ -48,22 +48,21 @@ If the Custom code is set up, the JCB manual will create the option for you to t
[00:13:52](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m52s) [00:13:52](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m52s)
It is a drag and drop field. It is actually a note as may be seen. Some HTML is used in the description and some JavaScript is being added to this footer of wherever this field is being used.[00:14:16](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m16s) This code is part of the process, there is much more code but this is what is needed to reuse quite often. I improve this in many areas and then I would always have to come back here(JavaScript). There are certain text that differs from each place. [00:14:37](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m37s ) For example: The word 'teaser', needs to be different everywhere else and the word 'image', sometimes it must be 'images' and not just 'image'. This code has been taken and added to a custom code. Set it as JCB manual, and in all places where dynamic script updates are needed, the 'arg' values are added. More info about the 'arg' values may be read in this note above.(See video) [00:15:19](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m19s) To make it simply 'arg'. These 'arg' areas is like placeholders. Strings or values may be passed via this Custom code placeholder and it gets updated on the fly during compilation everywhere where it uses this code snippet in JCB. [00:15:44](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m44s) This gives me a bit of that object orientated feeling where I write a function or a piece of script once, then I can reuse it everywhere else, and simply update the values being passed to it. It is by far not error proof there, you can not use any commas, and plus signs in these values. [00:16:15](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m15s) It needs to be one word. It can have a dollar sign if you want to have it place a dollar sign symbol in the code, but it doesn't execute the string that you pass. It will literally just paste it in wherever you've placed this 'arg' placeholder. You can add as many values to this 'arg' values as you want. Always make sure that the amount of values that is in the code must correspond to the amount of values that you are passing to it. [00:16:54](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) Otherwise you would end up having a certain area of the code, the 'arg' placeholder will not be replaced with anything. It will stay like that if it does not have a value for it. Back in the field a placeholder is added. [00:17:28](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m28s) Since it is 'id 1', three values gets passed to it, 'image', 'image' and 'teaser'. Which will then correspond to the replacing arg values. So that '0' would be 'image', this '1' value here would be 'image', and this '2' would be 'teaser'. It will actually replace it on compilation. Now it is possible to reuse this code anywhere else in JCB. It had been saved previously, so I am going to close it and open another one. [00:18:03](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) Here is one called; 'poster', which is doing the same thing. Now passing 'image', 'image' and then 'poster'. That means on this area it will change that '2 arg' value which is actually the third one. It will update it to 'poster' instead and so there is the functionality to have dynamic code in custom code, which can be reused all over JCB. It is a drag and drop field. It is actually a note as may be seen. Some HTML is used in the description and some JavaScript is being added to this footer of wherever this field is being used. [00:14:16](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m16s) This code is part of the process, there is much more code but this is what is needed to reuse quite often. I improve this in many areas and then I would always have to come back here(JavaScript). There is certain text that differs from each place. [00:14:37](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m37s ) For example; The word 'teaser', needs to be different everywhere else and the word 'image', sometimes it must be 'images' and not just 'image'. This code has been taken and added to custom code. Set it as JCB manual, and in all places where dynamic script updates are needed, the 'arg' values are added. More info about the 'arg' values may be read in this note above. (See video) [00:15:19](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m19s) To make it simply 'arg'. These 'arg' areas are like placeholders. Strings or values may be passed via this Custom code placeholder and it gets updated on the fly during compilation everywhere where it uses this code snippet in JCB. [00:15:44](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m44s) This gives me a bit of that object-orientated feeling where I write a function or a piece of script once, then I can reuse it everywhere else, and simply update the values being passed to it. It is by far not error-proof there, you can not use any commas, and plus signs in these values. [00:16:15](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m15s) It needs to be one word. It can have a dollar sign if you want to have it place a dollar sign symbol in the code, but it doesn't execute the string that you pass. It will literally just paste it in wherever you've placed this 'arg' placeholder. You can add as many values to this 'arg' values as you want. Always make sure that the number of values that is in the code must correspond to the number of values that you are passing to it. [00:16:54](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m54s) Otherwise you would end up having a certain area of the code, the 'arg' placeholder will not be replaced with anything. It will stay like that if it does not have a value for it. Back in the field, a placeholder is added. [00:17:28](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m28s) Since it is 'id 1', three values gets passed to it, 'image', 'image' and 'teaser'. Which will then correspond to the replacing 'arg' values. So that '0' would be 'image', this '1' value here would be 'image', and this '2' would be 'teaser'. It will actually replace it on compilation. Now it is possible to reuse this code anywhere else in JCB. It had been saved previously, so I am going to close it and open another one. [00:18:03](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m03s) Here is one called; 'poster', which is doing the same thing. Now passing 'image', 'image' and then 'poster'. That means in this area it will change that '2 arg' value which is actually the third one. It will update it to 'poster' instead and so there is the functionality to have dynamic code in custom code, which can be reused all over JCB.
### Difference Between Editor Changes And Custom Code Changes ### Difference Between Editor Changes And Custom Code Changes
[00:18:39](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m39s) [00:18:39](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m39s)
The only negative thing currently is that this kind of code that has dynamic values past to it, will not be updated by any changes which is made in the editor outside of JCB. [00:18:58](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m58s) The two functions do not fully merge at this stage. A snippet of code which has none of these 'arg', for example: If it is only used like this, without any extra values, that code will be replaced, if any changes is been made to it in the editor. [00:19:32](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m32s) It will start behaving like the initial implementation. It will be placed back into the component with that inserted tag above it, and if the diamond is placed in like it has been explained, it will get this inserted tag. If you have a custom code to which no values are being passed, it will add this '[inserted$$$]' around it, and then a diamond may be added in the editor. On compilation it will update that code in JCB and place it back into the new compiled component. [00:20:16](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m16s) The only negative thing currently is that this kind of code that has dynamic values past to it, will not be updated by any changes which are made in the editor outside of JCB. [00:18:58](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m58s) The two functions do not fully merge at this stage. A snippet of code which has none of these 'arg', for example: If it is only used like this, without any extra values, that code will be replaced, if any changes are been made to it in the editor. [00:19:32](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m32s) It will start behaving like the initial implementation. It will be placed back into the component with that inserted tag above it, and if the diamond is placed in like it has been explained, it will get this inserted tag. If you have a custom code to which no values are being passed, it will add this '[inserted$$$]' around it, and then a diamond may be added in the editor. On compilation, it will update that code in JCB and place it back into the new compiled component. [00:20:16](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m16s)
Amazingly it still works, but unfortunately the moment any arguments are passed to it,(see video) then we know that there are 'arg' placeholders in the Script like that. Since the script is now being used at multiple areas with multiple values. Say for instance, one of them is changed, it is not desirable that the database script is being replaced, because there would not be any indication as to where these 'arg' placeholders should be placed. [00:20:53](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m53s) The code at that stage has no reference whatsoever to these 'arg' values. The ideal is that all the 'arg' values Amazingly it still works, but unfortunately, the moment any arguments are passed to it,(see video) then we know that there are 'arg' placeholders in the script like that. Since the script is now being used at multiple areas with multiple values. Say, for instance, one of them is changed, it is not desirable that the database script is being replaced because there would not be any indication as to where these 'arg' placeholders should be placed. [00:20:53](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m53s) The code at that stage has no reference whatsoever to these 'arg' values. The ideal is that all the 'arg' values should be moved above the script. (see video)[00:21:14](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m14s) Perhaps to put some "convention of arg's", like that and then 'arg' and then 'equal' and then change this to value 'var', in this case, because it's JavaScript and that could possibly resolve the issue. [00:21:45](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m45s)
should be moved above the script.(see video)[00:21:14](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m14s) Perhaps to put some "convention of arg's", like that and then 'arg' and then 'equal' and then change this to value 'var', in this case, because it's JavaScript and that could possibly resolve the issue. [00:21:45](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m45s)
While it is in the process of improvement, this area should not be updated in the database but the rest should be updated. In that case use 'value' wherever 'arg0' is to be found. (see video) Then only care should be taken of this area and this area can be dynamically updated. [00:22:22](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m22s) Development is being done in order to make it possible that if a change is made in the editor, that it should also get updated in the database. While it is in the process of improvement, this area should not be updated in the database but the rest should be updated. In that case use 'value' wherever 'arg0' is to be found. (see video) Then only care should be taken of this area and this area can be dynamically updated. [00:22:22](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m22s) Development is being done in order to make it possible that if a change is made in the editor, that it should also get updated in the database.
If there is any change to these limitations, these notes(See video) will change. [00:22:56](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m56s) That is the other feature that has been added and that is to create custom code and then to reuse it across multiple areas of your component, without the complexity to update it every where again. You must be familiar with PHP or whatever language you are targeting with this custom code so that by this placeholders and by everything else may determine if that it actually works. [00:23:28](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m28s) Unfortunately if it does not work that debugging etc. is your responsibility. If there is any change to these limitations, these notes(See video) will change. [00:22:56](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m56s) That is the other feature that has been added and that is to create custom code and then to reuse it across multiple areas of your component, without the complexity to update it everywhere again. You must be familiar with PHP or whatever language you are targeting with this custom code so that by this placeholders and by everything else may determine if that it actually works. [00:23:28](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m28s) Unfortunately if it does not work that debugging etc. is your responsibility.
### The Component placeholder, and the View placeholder ### The Component placeholder, and the View placeholder
[00:23:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m43s) [00:23:43](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h23m43s)
The component placeholder, and the view placeholder is still functional. If this specific script is going to end up somewhere under a specific view, because the field script gets added to the view footer, then you have a view placeholder which basically is just also (((view))). So that is how a view dynamic update can be done of anything, if you need to use the view string name any where in the script. That means you have component with the uppercase[[[Component]]] [00:24:39](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m39s) and all uppercase and all that variations. Unfortunately, only that current view that is being targeted will be added to that placeholder in lowercase. [00:25:11](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m11s) I will compile this and then in the code show where it has been added. The component that it is using at the moment is 'registry'. Install it, and look where the code should have been added. [00:25:41](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m41s) So in the code we see there the 'image' has been updated with 'image', 'teaser' and 'images' placed there, as well as in all the other areas where those 'arg' placeholders appear, all have been updated. The code itself has been inserted in the correct area. That is custom code in a different implementation which is called the JCB manual option.[00:26:14](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m14s) If more information is needed about the 'hash' automation option, then watch the previous tutorial on YouTube. The component placeholder and the view placeholder is still functional. If this specific script is going to end up somewhere under a specific view, because the field script gets added to the view footer, then you have a view placeholder which basically is just also (((view))). So that is how a view dynamic update can be done of anything if you need to use the view string name anywhere in the script. That means you have a component with the uppercase[[[Component]]] [00:24:39](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h24m39s) and all uppercase and all those variations. Unfortunately, only that current view that is being targeted will be added to that placeholder in lowercase. [00:25:11](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m11s) I will compile this and then in the code show where it has been added. The component that it is using at the moment is 'registry'. Install it, and look where the code should have been added. [00:25:41](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h25m41s) So in the code we see there the 'image' has been updated with 'image', 'teaser' and 'images' placed there, as well as in all the other areas where those 'arg' placeholders appear, all have been updated. The code itself has been inserted in the correct area. That is custom code in a different implementation which is called the JCB manual option. [00:26:14](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h26m14s) If more information is needed about the 'hash' automation option, then watch the previous tutorial on YouTube.