Updated 015 Adding Templates and Layouts to a Site View (markdown)

Amigo 2019-06-19 11:54:28 +02:00
parent dd29efe9e7
commit 0ecc2d799e
1 changed files with 5 additions and 6 deletions

@ -26,12 +26,11 @@ Layouts work a little different.Is there a layout in this site view? It seems te
### Explanation Templates / Layouts Within Joomla
[00:08:02](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m02s) Templates have access to the global values, or the class values whereas layouts do not. It is important that this value needs to be passed to the layout. <<<<<<<
[00:08:02](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m02s) Templates have access to the global values, or the class values whereas layouts do not. It is important that this value needs to be passed to the layout because if you look at these snippets, you will see that we're just passing it 'this items'. But you can even pass it just 'this' or you could pass it a specific value. [00:08:29](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m29s) If you have custom classes, you can pass it that specific value from the custom class.
When a layout is set up there is a area(see video) where the dynamic get is selected that is used in the layout. It is not going to add that dynamic get to the site view or to the model. [00:08:53](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m53s) It only helps that the snippets can be viewed and it helps to set up this(See video) snippet. If the wrong code is selected in the layout, it will only change the way it looks but it can be overrided. The snippet can be copied and placed in the code where it need to be used. [00:09:18](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s)
Then the area can be changed which is passing the information to the layout, because the layout does not have access to it. It needs to be passed through the values that you want to use in it. But this(see video) script renders a layout. This is what Component Builder needs to add a layout to the components layout folder. [00:09:51](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m51s) It looks for a layout with that 'name' in the layouts list. These layouts need to be set up before it can be included into other views and templates. Do note that the layout concept and implementation together with the template is the same in the custom admin view. It works exactly the same. [00:10:19](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m19s) By adding the snippet to the default view, Component Builder is able to add that layout to the component, and adds that layout template to that site view.
Now that's important point, because if you look at these snippets, you will see that we're just passing it 'this items'. But you can even pass it just 'this' or you could pass it a specific value. [00:08:29](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m29s) You have your custom classes, you can pass it that specific value from your custom class. It all depends and when you setup the layout. You have an area just like this(see video) where you select the dynamic get that you are using in the layout. Now that is not going to add that dynamic get to your side view or to the model. [00:08:53](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m53s) It just helps you to see the snippets. It helps us to set up the snippet for you. If you've selected the wrong code here in your layout, we'll talk about that again when we get to layouts. It will actually just changed the way it looks here. But you can obviously override it. You can copy this snippet like that. Put it in your code where you want to use it. [00:09:18](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m18s)
Then you can just change that area that is passing the information to the layout, because the layout has not got access to this. You need to pass it through the values that you want to use in it. It will still look at how exactly that is done and possibly I will explain it again. But this(see video) script renders a layout. This is also how component builder knows it should add a layout to the components layout folder. [00:09:51](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m51s) It looks for a layout with that name in your layouts list. You need to have these layouts set up before hand. Before you can include them into other views and templates. Do note that the layout concept and implementation together with the template is the same in the custom admin view. It works exactly the same. [00:10:19](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m19s) And just by adding the snippet to the default view, component builder know it needs to add that layout to the component, and it knows it need to add that layout template to that site view. That is adding templates and layouts to a site view. And looking at the code seeing component builder builds these site views, because when we look at the default view, [00:10:50](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m50s) they are actually loaded here(see video), you see preacherbox, and there is preacherbox. There preacherpanel, there is preacherpanel. There is preachersmall and there is preachersmall. There is table, grid, and list. There is table, [00:11:10](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m10s) grid, and list. That is how you can add your code into smaller chunks. Next up we will look at setting up a template and making use of this implementation understanding the difference. That is adding templates and layouts to site views.
[00:10:50](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m50s)
When looking at the code it can be seen how Component Builder builds site views. Looking at the default view, can 'preacherbox' be seen in both areas and the same applies to ' preacherpanel', 'preachersmall', 'table', 'grid', and 'list'. [00:11:10](https://www.youtube.com/watch?v=6VBbi3Rl2eY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m10s) That is how the code can be added in smaller portions.