-
-
Notifications
You must be signed in to change notification settings - Fork 178
015 Adding Templates and Layouts to a Site View
Relationship Between Templates/Layouts In Views
Hi now that we've added a dynamic get to a site view, and we have looked at how to access the data sets through the examples snippets. We need to understand how layouts and templates link into site views. Basically to know 00:00:21 what is the site view in the code? What is the templates? What is the layout in the code itself? How Joomla load those things?
Preacher View Example
If we go to our example, component, sermon 00:00:39 distributor, and then view, and preacher, template or Tmpl. You see that there is a default.php file, 00:00:58 there is a default_preacherbox.php, default_preacherpanel.php, default_preachersmall.php files. A whole list of them. Those are all templates. The reason why we call them templates, it's because of the method by which they are included into the default file.
Preacher Site View Example
The Default file is the main file. 00:01:20 That's what we call the site view. So everything inside of this file, is actually build in the side view. Let's open the site view. All this code here is in default view. From here to there(see video) is added to that default file. So you see it says default view. 00:01:50
Location Of Templates
The way it adds to templates, it's with this snippet that says 'thisloadtemplatepreacherpanel'. You can get these snippets at the bottom of the site view. If you were to scroll down, you first will see the layout snippets and then after them the template snippets. You would scroll down to the one you have 00:02:19 made by looking at these names. And then here is preacher, grid, list, table, panel, box, small. That is the snippets that you will use. 00:02:37 You might sometimes change the way, possibly stay in the php instead of going out into the HTML. By the way that is what is happening up here if you look at the code. From time to time, I go out of the php(?>), I go into the php, with that tag(<?php), I go out of the php with that(>?). Then I go in again(<?), may go out again(>?), 00:03:04 and then I stay out that. I'm basically in HTML. So here is our HTML, and then this part here is 'uikit class' and the implementation. Then I go back into 00:03:20 php and I go out again, and here is HTML again. That is a way that you can work with php in the view.
Default View In Code
If we are going to look at this in the code, and we open that default.php file, you see that exactly what is placed there. So basically we end with php(>?) there 00:03:45 Then we go into php(<?) again. Here is the same text that we just looked at in that editor. That text gets placed here and then through these snippets, it includes the template. I'm using a global setting here. I'm checking how this global setting is set in the components global settings. I'm checking what type of display has been set. On the basis of that, I either show this template or that one or that one(see video) 00:04:22 in your template view you have access to the same global fields or class fields and public class methods as you have in the default view. In the default view we have access to 'this preacher' but the same is true of templates.
???? these are the templates that I've just opened And you see I'm using the same this params Here This preacher website so I am using the same Global Class Fields or values depends on how you wanna call it And that is true of your templates 00:05:07 So if we go back to our Interface the way that component builder knows that it needs to add this template to To this site View Is simply because of this code snippet so you place code snippet in there and you'll go look in the template List For a template with this name and it will simply add it To that site View now so what I mean I mean add it to this 00:05:35 Template with the In the right folder So You can you can by doing that Add your Templates to the site View And will look at setting up templates we also look at setting up Layouts, layouts work a little different Let me see do I have a layout here in this site View It seems I'm mostly using templates you can use templates and layouts in the site View 00:06:06 I have just used Templates mostly it seems And that means that possibly the layouts I've used in the templates View But if I wanted to add a template sorry a layout to this view Without doing it inside a template which doesn't matter it's just a way of bundling your Scripts in a more concise manner so that he doesn't be overwhelming When you look at the code but that you have it Broken up in pieces The layout structure is mostly used When you are dealing with a part of the display area 00:06:53 That is used across Other Display areas So I usually used the layout structure The moment I'm using a piece of code In more than one View Or in more than one template The reality is you could 00:07:12 You could use Template inside of templates You cannot use templates inside of layout But you can use templates inside of templates And you can use layouts inside of layouts But you cannot use templates in layouts and so but these are all conventions that are set forth because of the way Joomla implements the structure These are not limitations because of component Builder This is just how Joomla does it it will allow you to add templates to 00:07:44 The default Site view But It will not Allow you to add templates to a layout it will just scream at you And why Well the easiest way to put this Templates 00:08:02 Have access to the global values All the class values Where is layouts do not You need to pass layout the value that you wanna give it Now that's important Point because if you look at these Snippets You 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 You have your custom classes And 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 where you select The The Dynamic get that you were using in the layout Now that is not gonna add that dynamic get to your side view or to the model 00:08:53 It just helps you to see the Snippets And it helps us to set up The snippet for you So 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 wanna use it 00:09:18 And then you can just change that Area that Is passing the information to the layout because the layout has not got access to this And so you need to pass it through it 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 just script Basically renders a layout And this is also how component builder knows it should add a layout to the components layout folder 00:09:51 And it looks for a layout with that name in your layouts list So you need to have these layouts set up before hand Before you can include them Into other Views and Tablets And 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 And just by adding the snippet to the default View Component builder know it needs to add that layout to the component and knows at least Add that layout template to that site View Ok so that is adding Site views Sorry templates and layouts to a site View And Looking at the code seeing ok so Component builder builds these site views because when We look at the default View 00:10:50 They are actually Loaded here you see Preacherbox and there is preacherbox This preacher panel preacher panel There is Preacher small And there is preacher small and there is Table grid list there is Table 00:11:10 grid and list So that is how you can Add your code into Smaller chunks And next up will look at setting up a template And Making use of this implementation Understanding the difference So That is adding templates and layouts to site views
- Home
- Beta Testing
- Custom Code
- PHP Settings
- Demo Component
-
Tutorials
- Hello World JCB
- Intro JCB Guide
- JCB Installation Steps
- Planning Components
- Field Type Overview
- Basic Fields Creation
- Admin View Management
- Advanced Field Usage
- Admin Component Integration
- Component Setting Customization
- Scripting Components
- Component FTP Options
- Dynamic Get Method
- Site View DynamicGet
- Site View Templates
- Template Setup Guide
- Layout Configuration Steps
- Custom Admin Management
- Adding Site Views
- Custom Admin Integration
- MySQL Demo Tweaking
- Global JCB Settings
- Custom Time Field
- User Helper Integration
- Email Helper Usage
- Message Store Email
- List View Unescape
- Export Import Customization
- Overwrite Custom Fields
- List Field Filtering
- Automatic Code Import
- Manual Code Implementation
- Component Export Import
- Custom Admin Buttons
- Translation Management
- Site View Permissions
- Component SQL Updates
- Site Edit Configuration
- JCB Backup System
- Helper Structure Integration
- JCB v2.5 Upgrade
- Tab Setup Guide
- JCB v2.6 Release
- Extended HelloWorld
- Field Rule Validation
- Community Snippets Intro
- Snippet Forking Tutorial
- Pull Request Snippets
- Library Manager Area
- Excel-based Translation
- Dynamic Router Details
- Database Auto Updates
- Subform Quick Demo
- VDM Package Import
- Dynamic File Inclusion
- File Field Upload
- Drag-n-Drop Upload
- Quick HelloWorld JCB
- Non-database Fields
- Dashboard Customization
- Menu Prefix Toggle
- Community JCB Packages
- Collaborative JCB Workflow
- JCB Package Install
- JCB JAB18 Event
- Convenient New Fields
- Component Language Strings
- Library Functionality Anticipation
- Join Field Relations
- License Template Change
- Code Reusability
- Local Dev Environment
- Extended Field Types
- Joomla Custom Fields
- Custom Field Expansion
- Site View Listing
- Run Expansion Method
- Form Site View
- Field URL Update
- Additional Helper Methods
- Field Validation Rules
- New Placeholder Feature
- Component Config Params
- Per-field Default Values