Topics

Layout

Layout files are main files of a theme. They are responsible for generating theme's HTML code and linking theme assets.

Basically, these files are PHP files containing HTML tags and PHP code to embed ImpressPages functionality.

Main theme's layout file should be named as main.php and homepage layout file as home.php. Such consistent naming makes switching between themes easier.

Any PHP file, added to theme's root directory, will appear in admin panel as a layout file. If you want to hide some of the files from admin panel, prefix their names with underscore character (e.g., name it _header.php) or put in a subdirectory.

To learn how to create layout files, check out Quick Start theme's layout, which is provided in Themes/QuickStart/main.php file.

<?php echo ipDoctypeDeclaration(); /* Output HTML document type declaration. */ ?>
<html<?php echo ipHtmlAttributes(); /* Add attributes for HTML tag. */ ?>>
<head>
    <?php
    ipAddCss('assets/ipContent.css'); /* Add CSS for widgets */
    ipAddCss('assets/theme.css'); /* Add theme design CSS */
    echo ipHead(); /* Output HTML head, including title, meta tags, favicon,
CSS files (added by ipAddCss function) */
    ?>
</head>
<body>
    <div class="topmenu">
        <?php ipSlot('menu', 'menu1'); /* Generate a menu */ ?>
    </div>
    <div class="content">
        <?php echo ipBlock('main')->render(); /* Generate main content block */?>
    </div>
    <?php
        ipAddJs('assets/theme.js'); /* Add JavaScript file */
        echo ipJs(); /* Loading jQuery, CMS JavaScript files and files added with ipAddJs function */
    ?>
</body>
</html>

Add required CSS using ipAddCss() function. It adds CSS to the CSS stack. Then print all CSS files and other head items using ipHead() function. ipHead() function is required as it prints not only theme's CSS, but also CSS requested by plugins.

The same applies to JavaScript, just the functions are called differently ipAddJs() and ipJs()

ipHead() and ipJs() functions are mandatory in any layout for widgets to work!

404.php layout

 To make customization of error404 page easier, ImpressPages reserve 404.php layout. If you add such file to your theme, it will be used as the default layout to display "Page Not Found" message.

See also

comments powered by Disqus