set_layout
in template_helpers/theme.py
which decides the layout (vertical/horizontal). This option can be updated from config/template.py
file. Find
customization-options here
Below is the template Master file located at templates/layouts/master.html
. It includes styles and scripts files in Master Layout. You can find these files at the same path inside templates/layout/
folder.
{% load static %}
<!DOCTYPE html>
<html lang="en" class="{{navbar_type_class}} {{header_type_class}} {{menu_fixed_class}} {{menu_collapsed_class}} {{footer_fixed_class}} {{display_customizer_class}} {{content_layout_class}}" dir="{{text_direction_value}}" data-skin="{{skins}}" data-bs-theme="{{theme}}" data-assets-path="{% static '/' %}" data-base-url="{{url}}" data-framework="django" data-template="{{ menu_horizontal|yesno:'horizontal,vertical' }}-menu-{{ is_front|yesno:'front,' }}-{{ skins }}-{{ theme}}">
<head>
<title>{% block title %}{% endblock title %} | {% get_theme_variables 'template_name' %} - {% get_theme_variables 'template_suffix' %}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="description" content="{% get_theme_variables 'template_description' %}" />
<meta name="keywords" content="{% get_theme_variables 'template_keyword' %}" />
<!-- Og Meta -->
<meta property="og:title" content="{% get_theme_variables 'og_title' %}" />
<meta property="og:type" content="{% get_theme_variables 'og_type' %}" />
<meta property="og:url" content="{% get_theme_variables 'product_page' %}" />
<meta property="og:image" content="{% get_theme_variables 'og_image' %}" />
<meta property="og:description" content="{{ template_description }}" />
<meta property="og:site_name" content="{{ creator_name }}" />
<!-- Canonical SEO -->
<link rel="canonical" href="{% get_theme_variables 'product_page' %}">
<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="{% static 'img/favicon/favicon.ico' %}" />
<!-- Include the styles partial -->
{% include is_front|yesno:"./partials/styles_front.html,./partials/styles.html" %}
{% block vendor_css %}{% endblock vendor_css %}
<!--Page CSS-->
{% block page_css %}{% endblock page_css %}
<!-- Include the scripts partial (required ) -->
{% include is_front|yesno:"./partials/scripts_includes_front.html,./partials/scripts_includes.html" %}
</head>
<body>
<!-- remove while creating package -->
{% if ENVIRONMENT == 'production' %}
<div class="buy-now">
<a href="{% get_theme_variables 'product_page' %}" target="_blank" class="btn btn-danger btn-buy-now">Buy Now</a>
</div>
{% endif %}
<!-- remove while creating package end -->
<!-- beautify ignore:end -->
{% block layout %}
{% endblock layout %}
{% include is_front|yesno:"./partials/scripts_front.html,./partials/scripts.html" %}
<!--Vendors Javascript-->
{% block vendor_js %} {% endblock vendor_js %}
<!--Page Javascript-->
{% block page_js %} {% endblock page_js %}
</body>
</html>
Included styles file contains all the core css, theme css, demo css and more..
You can find this file at templates/layout/partials/styles.html
{% load static %}
<!--Fonts-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
<!-- Icons -->
<link rel="stylesheet" href="{% static 'vendor/fonts/iconify-icons.css' %}" />
<!--Vendor CSS-->
<link rel="stylesheet" href="{% static 'vendor/libs/perfect-scrollbar/perfect-scrollbar.css' %}" />
<!--Core CSS -->
{% if has_customizer %}
<link rel="stylesheet" href="{% static 'vendor/libs/pickr/pickr-themes.css' %}" />
{% endif %}
<link rel="stylesheet" href="{% static 'vendor/css/core.css' %}" />
<link rel="stylesheet" href="{% static 'css/demo.css' %}" />
This file includes helpers, customization, config js along with templateCustomizer initialization script :
You can find this file at templates/layout/partials/scripts_includes.html
TEMPLATE_CONFIG
object from template.py
.
{% load static %}
{% load i18n %}
<!-- Helpers -->
<!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
<script src="{% static 'vendor/js/helpers.js' %}"></script>
<!--? Template customizer: To hide customizer set display_customizer value false in config.js. -->
{% if has_customizer %}
<script src="{% static 'vendor/js/template-customizer.js' %}"></script>
{% endif %}
<!--? Config: Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file. -->
<script src="{% static 'js/config.js' %}"></script>
<!-- beautify ignore:start -->
{% if has_customizer %}
<script>
if (typeof TemplateCustomizer !== 'undefined') {
window.templateCustomizer = new TemplateCustomizer({
defaultTheme: "{{theme}}", // Required as system style can't decided without JS
{% if primary_color %}
defaultPrimaryColor: "{{ primary_color }}",
{% endif %}
defaultTextDir: '{% if rtl_mode %}rtl{% else %}ltr{% endif %}',
defaultSemiDark: {{ semi_dark_value }},
defaultShowDropdownOnHover: {{ show_dropdown_onhover_value }},
lang: '{{LANGUAGE_CODE}}',
controls: {{ customizer_controls | safe }}
});
}
</script>
{% endif %}
<!-- beautify ignore:end -->
This file includes main js along with template related vendor scripts :
You can find this file at templates/layout/partials/scripts.html
{% load static %}
<!--Core Javascript-->
{% if has_customizer %}
<script src="{% static 'vendor/libs/pickr/pickr.js' %}"></script>
{% endif %}
<script src="{% static 'vendor/libs/jquery/jquery.js' %}"></script>
<script src="{% static 'vendor/libs/popper/popper.js' %}"></script>
<script src="{% static 'vendor/js/bootstrap.js' %}"></script>
<script src="{% static 'vendor/libs/@algolia/autocomplete-js.js' %}"></script>
<script src="{% static 'vendor/libs/perfect-scrollbar/perfect-scrollbar.js' %}"></script>
<script src="{% static 'vendor/libs/hammer/hammer.js' %}"></script>
<script src="{% static 'vendor/js/menu.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
To set default layout to dark layout, just need to update config/template.py
file's style
option :
'TEMPLATE_CONFIG' => [
...
'theme' => 'dark',
...
],
Sneat provides built in support for RTL.
To use template default RTL Layout, you need to update config/template.py
file's rtl_mode
option.
If you want to set default layout to RTL, you can set this option to true
'TEMPLATE_CONFIG' => [
...
"rtl_mode": True,
...
],
You can set the layout in two ways:
Layout
property in the config/template.py
file.Layout
property in the page view.py
file. Refer Page Level Configurations
Below are the examples for different layouts which we have showcased in our template demo, Refer
apps/layouts/views.py
file for more details on page level customizations.
from web_project.template_helpers.theme import TemplateHelper
class CollapsedMenuView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"menu_collapsed": True,
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class ContentNavView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
return context
from web_project.template_helpers.theme import TemplateHelper
class ContentNavSidebarView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"is_flex": True,
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class HorizontalView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"layout": "horizontal",
"layout_path": TemplateHelper.set_layout("layout_horizontal.html", context),
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class WithoutMenuView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"is_menu": False,
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class WithoutNavView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"is_navbar": False,
"navbar_type": "hidden",
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class FluidView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"content_layout": "wide",
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class ContainerView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"content_layout": "compact",
}
)
TemplateHelper.map_context(context)
return context
from web_project.template_helpers.theme import TemplateHelper
class BlankView(TemplateView):
# Predefined function
def get_context_data(self, **kwargs):
# A function to init the global layout. It is defined in web_project/__init__.py file
context = TemplateLayout.init(self, super().get_context_data(**kwargs))
# Update the context
context.update(
{
"layout_path": TemplateHelper.set_layout("layout_blank.html", context),
}
)
TemplateHelper.map_context(context)
return context