From dea889f49d7f9c9afe5e2886d96068866ed90f1c Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Wed, 30 Oct 2019 06:37:15 +0200 Subject: [PATCH] Updated 074 How to add Joomla Custom Fields (markdown) --- 074-How-to-add-Joomla-Custom-Fields.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/074-How-to-add-Joomla-Custom-Fields.md b/074-How-to-add-Joomla-Custom-Fields.md index 8e50d25..fbb6c1f 100644 --- a/074-How-to-add-Joomla-Custom-Fields.md +++ b/074-How-to-add-Joomla-Custom-Fields.md @@ -59,7 +59,18 @@ You will be passing the ID and the Context and Joomla will automatically retriev [00:14:50](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m50s) -The Joomla web site currently is not setup to show the Looks. We are going to go to the menu and change that. Go to main menu and I'm going to click on Home. Select Demo, Looks. Save and close. We have Looks on the default page of the website. If we click Joomla Mount it should load and there is The Name. [00:15:29](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m29s) +The Joomla web site currently is not setup to show the Looks. We are going to go to the menu and change that. Go to main menu and I'm going to click on Home. Select Demo, Looks. Save and close. We have Looks on the default page of the website. If we click Joomla Mount it should load and there is The Name. [00:15:29](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m29s) You will see a list of Looks and The Name. If you click on The Name it shows us The Name and it shows there 1 hid. If we refresh that it shows 2 hid. That all works well, but our custom values which we have submitted is not showing up. The Name value is showing up and we could add some [00:15:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m55s) Description. This is also going to show up if we refresh the page. There's the Description, click The Name, there is the Description. All is showing up, but the real easy values are not showing up. We want them to be showing up on the page. That's what we are going to do for them. By simply using those [00:16:28](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m28s) event objects. In the code we have the onContentAfterDisplay, onContentBeforeDisplay, and onContentAfterTitle. + +### If You Forget How To Place The Component - Go To com_content open article, view.html.php + +[00:16:42](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m42s) + +If you forget how to use this or how to place the component, you can go to com_content and you can also open its article, view.html.php. You would see something very similar. Scroll down, you will see something, unless they've changed it by the time. But at this time the default of Joomla's implementation is very much the same. It's triggering the content and it's also placing it into these values. That means if you go to its template [00:17:19](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m19s) default php, you will see places, you could search for it. You could take this afterDisplayTitle, copy that go to the Default and place it in there(see video). You will see the content is generated by the content plugin event on. It echoes it out. You could use this code just like that copy, paste it into your component, after the title. The same goes with the other events. With the before display and after display. + +### Show How To Place Them In Our Component + +[00:17:58](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m58s) ??? -To see a list of looks and here's the name if you click on that It shows us the name And it shows as there's been one head and if we refresh that it shows two heads So That all works well But our custom values which we have submitted Is not showing up So This value is showing up and even we could add some [00:15:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m55s) Description And This is Also going to show up if we refresh the page here there's the description and we click here there is the description So all that is showing up but the real easy values are not showing up And we want them to also be showing up on the page And That's what we are going to do For them By Simply using those [00:16:28](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m28s) Event Objects So over here we have The Content after display content before display and content after title Now If you forget How to use this or how to place this The component that you can go to his this content [00:16:51](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m51s) Component And you can also open it's Article View And you would see something very similar scroll down down down here You see something well unless they've changed it by the time But at this time The default of Joomla's implementation is very much the same So it's also triggering the content and it's also placing it into these values which means that That if you go to it's template [00:17:19](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m19s) Default PHP You will see Places basically you could search for it so you could take this After title Copy that Come over here And place it in there and here you see Basically The content is generated by the content plugin event on And it basically just Echoes it out [00:17:44](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m44s) So you could use this code just like that copy paste it into your component After the title And the same goes with the other events So with the before display and after display So let me do that quickly I'm gonna just grab these and place them into our component So I've just copied them to a notepad like that I'm gonna move them to my other screen And then I'm gonna go back to to JCB And Go to my component The site view of a component [00:18:23](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m23s) And I'm going to open looking And in the component We have a whole lot of things happening here Basically we have a article Comment here And over here is the title So we want We want that Value [00:18:47](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m47s) To actually echo out After the title So We gonna take That first one Which is the event after the title I'm gonna place it Between the header and this diff Here So [00:19:05](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m05s) Basically There So that the content is generated by there and it's on content after title so this is the title And then when is gonna show over here Then we have another one on content before display Have the content before display I would like to think it needs to go first before anything So I wanna put that there On before anything displays That's way at the top [00:19:39](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m39s) And with content after display I wanna put that obviously at the very end Below everything So that's quite simple We could do more we could wrap it in a diff we could Do all kinds of styles to it But that's the simplest way and I'm just gonna demonstrate that Save and close here And then basically compile it again Install [00:20:08](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m08s) And now let's go refresh that page Oops I got some errors here I realized I'm using slightly different names then The ones I copied from the content You know the article area Content area let me show you that So They are saying up here in the comment on content before display and here it's before display content [00:20:35](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m35s) it's like a little bit Different So I'm using exactly the same So just Heads Up Use the the same as What is here in a comment And that's little me that always trying to Keep everything the same [00:20:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m55s) We save that it should work now So here we go simple Fields input value more fields with more input There are those values displayed on the front So if we go back here We can close this out Go back to the fields and let's say with a more fields You wanna change that to display after the title Save And then go back to the front and refresh this So now the one is up here and the other one is after the title [00:21:28](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m28s) So let's say we want simple field to actually show at the very end of our value go out of more Fields into simple field I will change that to you know After display Save and close So you could move the values Position Simply and everyone will move now you see that simple Field is below everything [00:21:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m55s) And if you realise This whole area here is the block So that's how the custom Fields can come to the front you can also say you know I don't want this Area to show up And you can go to To the field simple field And you could say show label hide label And save And now if you refresh it will only give you the value So [00:22:20](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m20s) That's the kind of behavioral integration So that's a quick demonstration Of how to now use Joomla custom fields in your components And how to then Model those values into the front end By Simply making use of the events And Wow have fun I'm sure this will Make things even more interesting Thanks for watching \ No newline at end of file + +Let me do that quickly. I'm going to grab these and place them into our component. I've copied them to a notepad. I'm going to move them to my other screen. And then I'm gonna go back to to JCB And Go to my component The site view of a component [00:18:23](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m23s) And I'm going to open looking And in the component We have a whole lot of things happening here Basically we have a article Comment here And over here is the title So we want We want that Value [00:18:47](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m47s) To actually echo out After the title So We gonna take That first one Which is the event after the title I'm gonna place it Between the header and this diff Here So [00:19:05](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m05s) Basically There So that the content is generated by there and it's on content after title so this is the title And then when is gonna show over here Then we have another one on content before display Have the content before display I would like to think it needs to go first before anything So I wanna put that there On before anything displays That's way at the top [00:19:39](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h19m39s) And with content after display I wanna put that obviously at the very end Below everything So that's quite simple We could do more we could wrap it in a diff we could Do all kinds of styles to it But that's the simplest way and I'm just gonna demonstrate that Save and close here And then basically compile it again Install [00:20:08](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m08s) And now let's go refresh that page Oops I got some errors here I realized I'm using slightly different names then The ones I copied from the content You know the article area Content area let me show you that So They are saying up here in the comment on content before display and here it's before display content [00:20:35](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m35s) it's like a little bit Different So I'm using exactly the same So just Heads Up Use the the same as What is here in a comment And that's little me that always trying to Keep everything the same [00:20:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h20m55s) We save that it should work now So here we go simple Fields input value more fields with more input There are those values displayed on the front So if we go back here We can close this out Go back to the fields and let's say with a more fields You wanna change that to display after the title Save And then go back to the front and refresh this So now the one is up here and the other one is after the title [00:21:28](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m28s) So let's say we want simple field to actually show at the very end of our value go out of more Fields into simple field I will change that to you know After display Save and close So you could move the values Position Simply and everyone will move now you see that simple Field is below everything [00:21:55](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h21m55s) And if you realise This whole area here is the block So that's how the custom Fields can come to the front you can also say you know I don't want this Area to show up And you can go to To the field simple field And you could say show label hide label And save And now if you refresh it will only give you the value So [00:22:20](https://www.youtube.com/watch?v=n5RBmP0uNCM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h22m20s) That's the kind of behavioral integration So that's a quick demonstration Of how to now use Joomla custom fields in your components And how to then Model those values into the front end By Simply making use of the events And Wow have fun I'm sure this will Make things even more interesting Thanks for watching \ No newline at end of file