Creating Templates
Before start developing you must disable Compile assets option from Admin panel -> Settings -> Advanced -> Internal settings -> Compile api.js - NO
Example path to settings: http://yourwebsite.com/admin/view:settings#option_group=advanced
Begining
Making a Microweber template is easy. You just have to make a new folder in userfiles/templates/. The template folder name must be in lowercase, and must not contain spaces or special characters, besides unserscore and dash.
Lets make a folder called starter at "userfiles/templates/starter"
Setting up the basic files.
Make few files in your new folder.
In /assets folder you can put your Images, CSS and JS files.
Set the template name in the config.php file
Open "userfiles/templates/starter/config.php" and put this code
Making header and footer
Every template needs header and footer files. They can be loaded within the template layouts to add the common styles and scripts needed for the website.
header.php
You can use the template_url() function to get the URL to the template folder. Also there is template_dir() for the full filesystem path of the template.
The curly brackets text like {content_meta_title}
is replaced with the appropriate content when the site is rendered.
footer.php
Put any closing tags in the footer and also common content like menu, copyright info, etc.
Adding navigation menus, logo, etc.
Its common that we put a navigation in the site header and also design elements that are used on all pages. Also we can put global editable regions, so the user can change its logo and text in the header.
You can load modules inside your template with the tag.
Module layouts
Creating module layouts
The creating of module layouts is easy. You have to create folder layouts/templates in your template folder, which must contain skin-1.php and skin-1.png where 1 is the increment number of layout. If you want to create more second or third layout, their names must be skin-2.php and skin-3.php with screenshots skin-2.png and skin-3.png
The structure of three must be the following:
The structure of module layout file must be the following:
skin-1.php
We recommend you to use the following structure for the first layout of your template because it's contain structure with Clean container which you can use to Drag & Drop elements inside.
For each next layout you can use the following structure:
skin-2.php
On the top of structure you see name label. The value will be shown as Title of the layout in right sidebar. The label position serv for ordering of layouts.
Bellow on the first line from the code you will see field="layout-skin-2-<?php print $params['id'] ?>"
. The number in red must be the increment number of your layout. This is the same number like on the filename of this layout.
Helper classes
We have some helper classes for different cases.
The class nodrop disables Drag & Drop in the element.
If you have wrapper with nodrop you can use allow-drop on inner elements to allow Drag & Drop function inside.
Example for nodrop and allow-drop:
If you have complex structure of code you can use safe-mode to prevent breaking the structure. You can use this class only for block elements.
For inline elements which must not be deleted, you can use safe-element.
Example for safe-mode and safe-element:
The cloneable class will show you tools over the element which allows you to duplicate, remove or move the elements.
You can also use style="background-image: url('http://image.url.path');". This inline style will show you handles for changing the background image of selected element.
Template layouts
Each template is made of "layouts"
Think of layouts as "pages" of your template. You can have just one layout... or as many as you like.
The vast majority of sites need more complex structure and that can be accomplished by adding a variety of page layouts to your template folder.
Microweber allows you to have different layouts for different pages in your site. Although each page layout can be different you can define common regions such as a "header", "footer" and a "sidebar" to share among layouts.
Every template can have multiple layouts. Besides a simple page, you can make different page layouts that can be used by the users and chosen at the page creation process.
Example of layouts usage is to allow the user to have different looking pages for their blog, shop or contact us
Making layouts
The layouts are located in your template folder or its sub-folders.
For example: "userfiles/templates/starter/layouts/"
The layout files are simply php files located in any sub-folder of your template. Microweber recognizes a layout file by scanning the template folder for php files which contains the following code in them.
Those layouts can show content from the current page or from other pages. They can even have shared editable regions. All you need to do is include your modules and write your code in the layout file.
index.php
"userfiles/templates/starter/index.php"
The index.php file is used as a homepage layout. This is your first layout. Layouts can be different for every page and this is defined from the admin, on the create page window.
We have created editable field in our layout by adding class edit to html element of our choice.
clean.php
"userfiles/templates/starter/clean.php"
This layout is used as default for pages and also as a fallback layout if no other layout can be found.
Creating blog layout
In a site where we want to have separation of how the pages and the posts look we will need to create different layouts for them.
Here, for example, is how we would make a layout for a blog page with a posts module and a sidebar.
Make a new file at "userfiles/templates/starter/layouts/blog.php", this file will load when you create new page with the "Blog" layout.
blog.php
blog_sidebar.php
Creating layout for post
We can have an inner page to show the posts added to our blog. Create a file blog_inner.php at userfiles/templates/starter/layouts/blog_inner.php to show posts added the blog layout pages. You can also make a file called post.php or inner.php in the root of the template folder and use it as a default for posts in all pages.
blog_inner.php
Creating shop layout
If we want to have a shop pages in out template we will need to make a shop layout and a layout to display products from the shop.
The shop layout is created by including is_shop property in the definition of the layout file. You can add products only to pages that are defined as shop by using a shop layout.
Make a new file at userfiles/templates/starter/layouts/shop.php, this file will load when you create new page and choose the "Shop" layout.
shop.php
shop_sidebar.php
As you may notice we have loaded the "categories"module in sidebar and "shop/products" module in our layout
Creating product layout
We can want to have a custom layout to show each of our products. Create a file shop_inner.php at "userfiles/templates/starter/layouts/shop_inner.php" to show products added the shop pages. You can also make a file called product.php in the root of the template folder and use it as a default for products in all pages that doesn’t have inner layout.
shop_inner.php
Creating checkout layout
You have to create a file checkout.php in root template folder /starter/checkout.php The file must contain the following code:
checkout.php
Here we loaded the module "shop/checkout".
That's all.
You can download our Starter template from this address: https://github.com/microweber-templates/starter
Last updated