Updated 032 JCB manual custom code implementation (markdown)

Amigo 2019-07-15 11:38:20 +02:00
parent 39c67a129b
commit 4f5d926284
1 changed files with 11 additions and 1 deletions

@ -22,7 +22,17 @@ There are two ways in which the code is added. It has been explained in the prev
### GitHub Explanation For Update And Insert Issue 37
There is also a note on GitHub about this which may be more logical. So here we are at Github. It's on issue 37 if you want to go look at it under the Joomla component on GitHub [00:06:55](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m55s) the component builder on GitHub. Basically to start inserting code, you would use this (///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///)as a placeholder, then your code on a new line, then when you're finished this(///&ast;&ast;&ast;[INSERT<>$$$$]&ast;&ast;&ast;///) would close that code block. Sometimes you don't want insert code, you want to replace code that was generated by JCB. Then you'd use the replace code placeholder(///&ast;&ast;&ast;[REPLACE<>$$$$]&ast;&ast;&ast;///). And then 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 from replaced. It adds it back without this diamond(<>) in between those dollar signs and inserted text or replaced text. [00:07:55](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m55s) It removes them because basically by doing that, it means that this code doesn't need to be updated. The moment you add those two back in there between those 2 values, next time component builder compiles. It actually knows this piece of code I need to check again and update whatever is in the database, because it's been changed. [00:08:25](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m25s) This diamond here tells it. There is a change you need to update. You will see that there is this new number being added next to the code. That number is actually the id of the database row [00:08:49](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m49s) that JCB is actually stored the code in. So if you change this number, you are going to have a problem. So don't change this number. JCB put this number in that he can know where to go update the code in the database. Once you've made any changes to the code, you would simply add this diamond(<>) back in, that's quite important otherwise it will not be [00:09:18](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s) be parsed, and it will be overwritten by what's in the database. That's the initial purpose of this new feature, was to be able in the editor, create code and then on the fly, have it become 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 [00:09:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m47s) remember it. If you want to change the code you just add these diamonds(<>) either for the insert or for the replace depending on what you did. It will automatically know there's been a change and it will first update what is in the database, and then store it back into the new compiled version. That is exciting in itself I realize [00:10:12](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m12s) it's a real stunning new feature. We have been doing some teething on some of its implementation. You can even read down here. There's some comments and things. We are at the moment at version 2.3.2 which is not yet released. I'm busy working on it because this new version 2.3.2 will include [00:10:41](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m41s) the extra feature which wasn't ever really discussed here on the forum. Because it was a feature that I've been hoping for quite some time. I've build quite a number of components with JCB by now. I've always had this issue that I would develop a very smart function, a custom script, inside of some view or some field or somewhere in JCB. I would like to use it again elsewhere [00:11:15](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m15s) but then I have to copy it, go pasted there. And it will happen that I would improve it there. Add this little thing there and I debug this. Improve the whole function, maybe just pieces script or whatever, I just improves it. And then it where I took it from does I need to know copy again back there. It's always this copy and move and then obviously there's variables inside that needs to be different names. [00:11:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s) This always been a very unpleasant experience.
[00:06:33](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m33s)
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.
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.
[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. In develop a very smart function, a custom script, inside of some view or some field or somewhere in JCB. I would like to use it again elsewhere [00:11:15](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m15s) but then I have to copy it, go pasted there. And it will happen that I would improve it there. Add this little thing there and I debug this. Improve the whole function, maybe just pieces script or whatever, I just improves it. And then it where I took it from does I need to know copy again back there. It's always this copy and move and then obviously there's variables inside that needs to be different names. [00:11:47](https://www.youtube.com/watch?v=KiAtJawZ3oo&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m47s) This always been a very unpleasant experience.
### Custom Codes In JCB