Templates Basics
Last updated
Last updated
Microweber templates are a set of files that determines the overall look of a website. These files are used to generate the site layout and the html code.
You can use PHP and HTML to make your template as flexible as you need it to be.
All templates are located into userfiles/templates
directory. Each template is contained within its own folder and you need to create a new folder when creating a new template. Usually, the name of the folder is given the name of your new template.
Template folders must be in lower-case and must not contain spaces or special characters.
Here is the most basic template structure
###Basic files and their purpose
Filename | Description |
---|---|
Here is example config file you must create in your template folder
####Set template name, author and version
The config.php
file must contain a $config
array with the following information.
The config file defines the name of your template as it will appear in the "Template selection" menu and in the "Settings" area.
The version parameter is optional and its used if you want to offer updates.
In the common case every template have a lot of files, those may be images, css files, javascripts and what not. You can put those files in the template folder and load them in your layout file
To add some basic styling, please create a css/ folder inside your theme folder and add some CSS in css/theme.css
You can add a module in your template if you want to show dynamic content or work with some custom functionality
The modules are added with <module type="name_of_your_module" />
| Constant | Value | | PAGE_ID
| The id of the current page or 0 if page is not found | | POST_ID
| The id of the current post or 0 if you are not in a post | | CATEGORY_ID
| The id of the current category or 0 if you are not in a category | | MAIN_PAGE_ID
| The id of the parent page if you are in a subpage | | ROOT_PAGE_ID
| The id of the root parent page if you are in deep sub-page |
The editable regions are the places where the users can drag and drop modules and edit content in real time.
You can define as few or as many regions that you like
Every layout can have many editable regions.
You can define editable regions in your template where the user will be able to type text and Drag and Drop modules The content of this region will be dynamic and will be editable on every layout that includes it.
Here is how it looks like:
The classes nodrop and allow-drop give you more control over which elements can or can not accept new elements. The nodrop class remove the ability to insert element and allow-drop enables it again. For example:
Microweber provides 2 types of editing logics - regular mode and safe mode. Regular mode is the default editing case in which you can add format or delete elements. Safe mode is more strict way of editing. It adds various restrictions that prevent user from breaking the deasign of selected section. The class *safe-mode * activates safe mode or an element and it's children, and regular-mode restres the regular mode.
Function | Value |
---|---|
Variable | Value |
---|---|
config.php
holds the information for your template, like name, version
index.php
homepage default layout
header.php
site header
footer.php
site footer
clean.php
default layout for page
inner.php
default layout for post
template_url()
http://example.com/userfiles/templates/my_template/
template_dir()
/home/user/public_html/userfiles/templates/my_template/
$content
Array of the current content item, it can be page or post
$page
Array with the data for the current page
$post
Array with the data for the current post