v5.6.7Gantry 5.6.7 has been released!Read announcement

Gantry 5: A Template Developer’s Point of View

To be a template developer these days is quite exciting! You express your ideas and emotions with the products you release, you learn new things every day, and all this in a very big and competitive industry!

But the good template developer should always be up-to-date with the latest technologies and tools in order to stay competitive and develop modern, optimized products.

One of these tools is the Gantry 5 Framework, and as a template developer, I would like to share my experience with it, how it makes my day-to-day job easier, how it helps me to develop great templates, and the features in it that I love the most!

As the guys at RocketTheme say, “Gantry 5 is built with the modern Web in mind.” It really is! It incorporates the latest Web technologies, such as: HTML5, CSS3, SCSS, the Flexbox model, and so on and so forth. All of these things give the developers amazing flexibility, and allow them to quickly build great sites.

Below, I will outline some of the things that I love most in Gantry 5, and how they incorporate into my Joomla! template development business.

SCSS (and Twig) Variables Being Automatically Created

With Gantry 5, you no longer need to declare your variables in the PHP, SCSS, TWIG, XML or similar files. Once you write your YAML code, Gantry 5 takes the parameters and does everything for you. It’s as simple as that.

To demonstrate this feature, we will add a menu item font size option in the administrator as an example:

Screenshot: menu font size setting that creates an SCSS variable

The following steps are intended to serve as an example for template developers. Editing default template files is an advanced process, and users editing existing templates would likely use custom override files to accomplish this. More details on that process are available in the Gantry 5 documentation.

First, open the base.yaml file (root/templates/g5_hydrogen/blueprints/styles) and add the following code on line 24, just above the favicon block:

    menu-font-size:
      type: input.text
      label: Menu Font Size
      description: Specify the default Menu font size in rem, em or px units.
      default: "1rem"
      pattern: 'd+(.d+){0,1}(rem|em|px)'

That’s it! Now you have the base-menu-font-size SCSS variable available, and you can start using it.

You do want to set a default value (fallback) for your SCSS variables. In this case, open the _typography.scss file (root/templates/g5_hydrogen/scss/configuration) and add the following code at the bottom:

// Menu Sizes
$base-menu-font-size:       1rem !default;

Now you just need to hook the Menu Font Size option in your SCSS so the value you enter in the administrator appears on the front end. Open the _typography.scss file (root/templates/g5_hydrogen/scss/hydrogen) and add the following code:

.g-main-nav {
    font-size: $base-menu-font-size;
}

And while we are on SCSS, I would like to mention that the awesome Bourbon mixin library is already built in to the Gantry 5 core!

THE PARTICLES SYSTEM

No more Custom HTML modules!

Now, we have user-friendly particles that enable the user to do pretty much everything from the administrative panel without the need to touch any code. Thanks to the Input Fields that come with Gantry 5, you can create any type of particle and the users will just set the options they want via the GUI.

Let’s build a “Call-to-action Button” particle as an example:

Screenshot: call-to-action button particle example

First, create a new file in root/templates/g5_hydrogen/particles and call it ctabutton.yaml. In this YAML file, we list all of the parameters and input fields, so they can render as nice options in the administrator, and later on render in Twig. This will then generate the final HTML output on the front end.

Paste the following YAML code in the file:

name: CTA Button
description: Displays a Call-to-action button.
type: particle

form:
  fields:
    enabled:
      type: input.checkbox
      label: Enabled
      description: Globally enable to the particles.
      default: true

    introtext:
      type: input.text
      label: Intro Text
      description: Enter the Intro Text

    buttontext:
      type: input.text
      label: Button Text
      description: Enter the Button Text

    buttonicon:
      type: input.icon
      label: Button Icon
      description: Select the Button Icon

    buttonlink:
      type: input.text
      label: Button Link
      description: Enter the link address

Next, you will want to create a new file in root/templates/g5_hydrogen/particles and call it ctabutton.html.twig. Here, you define the markup.

Paste the following Twig code in the file:

{% extends '@nucleus/partials/particle.html.twig' %}

{% block particle %}
    <div class="g-cta">
        <div class="g-cta-intro">
            {% if particle.introtext %}<h2>{{ particle.introtext|raw }}</h2>{% endif %}
        </div>
        <div class="g-cta-button">
            {% if particle.buttontext %}
                <a href="{{ particle.buttonlink|e }}" class="button">
                    {% if particle.buttonicon %}
                        <i class="{{ particle.buttonicon }}"></i>
                    {% endif %}
                    {{ particle.buttontext|raw }}
                </a>
            {% endif %}
        </div>
    </div>
{% endblock %}
  1. Style the particle as you wish via SCSS.

You will find more details about particle creation in the Gantry 5 documentation.

And while we are on particles and Twig, I would like to mention that Gantry 5 comes with some very handy, predefined Twig blocks which allow you to load your style sheets and scripts in different elements on the website:

Load Stylesheet in the <head>.

{% block stylesheets %}
    {{ parent() }}
    // Your stylesheet goes here
{% endblock %}

Load JavaScript in the <head>.

{% block javascript %}
    {{ parent() }}
    // Your script goes here
{% endblock %}

Load JavaScript before </body>.

{% block javascript_footer %}
    {{ parent() }}
    // Your script goes here
{% endblock %}

Streams for File Locations

Gantry 5 comes with some predefined streams that template developers can use while coding. It speeds up the development process, and at the same time keeps the code nice and clean:

  • gantry-assets (for example gantry-assets://js/) points to root/media/gantry5/assets/js/.

  • gantry-engine (for example gantry-engine://scss/) points to root/media/gantry5/engine/nucleus/scss/.

  • gantry-theme (for example gantry-theme://scss/) points to root/templates/current_theme(g5_hydrogen)/scss/.

  • gantry-admin (for example gantry-admin://images/) points to root/templates/current_theme(g5_hydrogen)/admin/images/.

Multi-level Overrides

This is another great feature of Gantry 5, especially for the template developers.

What I mean by “multi-level overrides” is that you can override the core Gantry 5 files, the default Joomla files, or the extensions files in your template. Then the user can override your overrides. Here’s an example:

  1. In order to override the page.html.twig file (root/media/gantry5/engines/nucleus/templates/) you need to copy it in root/templates/g5_hydrogen/engine. If the engine directory does not exist you need to create it.

  2. Then the user can override your page.html.twig by copying it from root/templates/g5_hydrogen/engine and pasting it in root/templates/g5_hydrogen/custom/engine. Any changes they make there will become the dominant override, and will remain safe from being overwritten in the event of a template update.

The Revolutionary Layout Manager

And last, but definitely not least, the awesome Layout Manager. It is such an amazing feature in Gantry 5 that it extends the CMS functionality tremendously!

The users are the ones that will experience the great power of the Layout Manager.

It includes features like drag-and-drop functionality for particles, module positions, and atoms. There is also a virtually unlimited number of module positions you can create, the adjustable block width, and more.

There are some very nice things for template developers, as well. You can add custom classes and attributes to every single section and block. This is very handy in case you want to add on-scroll animation, for example.

There are many, many other awesome features in Gantry 5. For example, the new Menu Editor and the Outlines system, but these are out of the scope of this blog post.

As you can see, Gantry 5 is a really powerful tool that eases the developers life greatly. You basically have everything you need to develop great products, and at the same time, you also get an incredible performance.

Just give it a try and I’m sure you’ll love it!

This has been a guest blog post submitted by Ivo Valkov (JoomFX), a Web developer and member of the Gantry community.

Next Post

Previous Post

Implementing Fixed Navigation/Header on Scroll

These days, websites are much more interactive than what they were even just a couple of years ago. Quickly evolving technology brings about some really nice solutions which, themselves, set new trends in the Web design industry.

One of these trends, which actually became very popular, is the fixed header on scroll. A fixed header is a section of the page that moves with you as you scroll down the page.

The process outlined in this guide has since been rendered obsolete after continued improvement and development of Gantry 5. There is a much easier process in place for achieving this, and you can find out more about it through this blog post.

There is a good reason for its popularity – the fixed header is a great UX improvement as it allows the visitor to browse the website without the need to scroll to the top of the page in order to see the navigation controls.

In this article, I will show you how to implement the Fixed Header in Gantry 5’s Hydrogen template using the well-known headroom.js script.

Headroom.js is a lightweight, high-performance JavaScript widget (with no dependencies!) that allows you to react to the user’s scroll. It is licensed under the MIT License so you can use it in both personal and commercial projects.

So, let’s get started…

Download headroom.js

You can download Headroom.js from Github. You can also just load the script from a CDN, but I always prefer to have all my scripts run locally in case the CDN is not available. However, there are some benefits of loading your scripts remotely, but this is beyond the scope of this tutorial.

Once you download it, you need to unzip the headroom.js-master.zip file. You will find several files and folders, but the one you need is called dist. In the dist folder, you will see three different versions of headroom.js – one written in Angular, one in jQuery and one in pure JavaScript. I strongly recommend the pure JS one, headroom.min.js, as you will not need to load additional JS libraries which will add more weight to your website.

Copy headroom.js in Hydrogen

As described in the Gantry5 Documentation, you need to keep all your modifications and additions in the SITE_ROOT/templates/g5_hydrogen/custom/ directory so they do not get overwritten when you update the template.
Then, create the SITE_ROOT/templates/g5_hydrogen/custom/js/ directory structure and copy the headroom.min.js file there.

Loading headroom.js in Hydrogen

Now you need to load the script in the template. You can do that with the Custom CSS/JS atom from the Layout Manager, but since it is a global script that needs to be loaded on all pages, it is probably a better idea to hard code it in the template. For this, we need to create a template override of the page.html.twig file:

  1. Create the SITE_ROOT/templates/g5_hydrogen/custom/engine/templates/ directory structure.
  2. Go to SITE_ROOT/media/gantry5/engines/nucleus/templates/ and copy the page.html.twig file.
  3. Paste the page.html.twig file in the directory structure you created in step 1.
  4. Edit the SITE_ROOT/templates/g5_hydrogen/custom/engine/templates/page.html.twig file and add the following code on line 61, just below the main.js one:
<script type="text/javascript" src="{{ url('gantry-theme://custom/js/headroom.min.js') }}"></script>
    <script>
        // grab an element
        var myElement = document.querySelector("#g-navigation");
        // construct an instance of Headroom, passing the element
        var headroom  = new Headroom(myElement);
        // initialise
        headroom.init();

        // grab an element
        var myElement = document.querySelector(".g-offcanvas-toggle");
        // construct an instance of Headroom, passing the element
        var headroom  = new Headroom(myElement);
        // initialise
        headroom.init();
</script>

As you can see in the above code, we are making the Navigation section and the Offcanvas toggle sticky. If your menu is in the Header section (not in the Navigation section) then you need to replace #g-navigation with #g-header in the code above.

Now you have headroom.js implemented in your website. If you inspect your website with Firebug or Chrome Inspect Element, you should see the headroom classes being added.

Screenshot: loading headroom.js in the Hydrogen theme

Adding the Style (SCSS)

Now, you need to add the style which will actually tell the browser that the particular element should be fixed/sticky when the visitor starts scrolling:

First: Create the custom.scss file as described in the Gantry Documentation and paste the following code there:

@import "dependencies";

#g-navigation.headroom--not-top {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1001;
    left: 0;
}

.g-offcanvas-toggle.headroom--not-top {
    position: fixed;
    z-index: 1002;
}

.g-offcanvas-open {
    #g-navigation.headroom--not-top {
        left: $offcanvas-width;
    }
    .g-offcanvas-toggle.headroom--not-top {
        left: $offcanvas-width + 0.7rem;
    }
}

#g-navigation.headroom--not-top, .g-offcanvas-toggle.headroom--not-top {
    @include transition(all 0.3s);
}

Or if you want to have a more advance behavior you can use the following code instead of the above one:

@import "dependencies";

//Fixed Header On Scroll - Advanced
.headroom {
    @include transition(transform 200ms linear);
}
.headroom--pinned {
    @include transform(translateY(0%));
}
.headroom--unpinned {
    @include transform(translateY(-100%));
}

#g-navigation.headroom--not-top {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1001;
    left: 0;
}

.g-offcanvas-toggle.headroom--not-top {
    position: fixed;
    z-index: 1002;
    &.headroom--unpinned {
        top: 0;
    }
}

.g-offcanvas-open {
    #g-navigation.headroom--not-top {
        left: $offcanvas-width;
    }
    .g-offcanvas-toggle.headroom--not-top {
        left: $offcanvas-width + 0.7rem;
    }
}

#g-navigation.headroom--not-top, .g-offcanvas-toggle.headroom--not-top {
    @include transition(all 0.3s);
}

Second: Recompile the CSS for the “Base” Outline in the Gantry 5 administrator

There you go! You now have a very nice and clean fixed Navigation/Header on scroll.

This has been a guest blog post written by Ivo Valkov (JoomFX), a Web developer and member of the Gantry community.

Next Post

Previous Post

Gantry 5 RC3 Released

Gantry 5 RC3 (Release Candidate) is now available. Comprised of 290+ commits, 105+ issues, and 10+ pull requests, RC3 is the largest single update to Gantry 5 since the initial beta.

In a giant leap forward towards Gantry 5’s first full release (5.0.0), RC3 focuses on implementing a large number of community-inspired improvements, bug fixes, and optimizations.

In this article, we’ll take a quick look at some of the changes included in Gantry 5 RC3.

If you would like to give Gantry 5 RC3 a look yourself, you can download both it and the free Hydrogen template now. You can also take a look at the project roadmap, including a detailed changelog for Gantry 5 RC3 here.

New Gantry 5 Joomla Module: Gantry 5 Particle

Gantry 5 Particle

Gantry 5 for Joomla now comes with a new module that allows you to create a Gantry 5 Particle and have it treated exactly like any other Joomla module.

This enables you to create a new module position in your layout, and assign a Gantry 5 Particle module to it, taking full advantage of Joomla’s module system. This is optional, of course, as you can still place particles directly into your layout. This just gives you more flexibility when working with content that would benefit from Joomla’s module system.

Automatic custom.scss recompilation

Production Mode

We added a new option in the Gantry 5 System plugin that allows you to switch between Development and Production modes.

When in Development, any change made to the custom.scss file will be detected by Gantry, triggering an automatic recompilation of the file. This makes it easy to make changes on the fly and have them appear on your site without any extra action required on your part.

In the future, more Development vs. Production actions will be tied to this same setting, such as Cache, minified vs. extended JS/CSS, etc.

Dependencies.scss

We have now consolidated the includes for Bourbon, Nucleus, theme mixins, and variables into a _dependencies.scss file. You can now just import it to have it all. Use @import "dependencies"; in your custom.scss file.

Offcanvas reworked

One of the biggest concerns addressed by the community has been about the difficulty of using fixed elements and/or backgrounds, due to the transform applied on the #g-container and used by the Offcanvas to animate. This is no longer a problem! We moved away from transform and instead are using left and right animations.

Menu animations

Thanks to the contributions by JoomFX, it is now possible to change the animations of the Menu dropdowns. You can choose between: No animation, Fade, Zoom, Fade In Up.

New Breakpoint

Breakpoints

Thanks to the contribution of adi8i, the mobile menu now has a new independent breakpoint that can be customized to let the navigation menu switch to the mobile menu. These breakpoint settings can be found at the bottom of the Styles administrative panel in the Configuration Styles area.

Breakpoints are a great way to customize the user experience for your site on various devices, allowing for you to easily hook in to responsive points to provide an experience catered to mobile phones, tablets, and desktops.

Admin improvements

Collapsed

All cards in the Styles and Settings panels (including Swatches) are now collapsible, and their state will be remembered for the domain. On the next reload, collapsed/expanded cards will be restored.

Assignments cards are now wrapped into scrollbars to keep the page smaller. This is especially useful on large sites with an abundance of content. When using a filter, cards with no items that match your search criteria are hidden.

Module Instance

It is also easier to change the Module ID of a Module Instance particle through modal.

WordPress

Our work hasn’t just been focused on Joomla, either. In fact, we have made great progress towards bringing Gantry 5 to WordPress. We have some work left to do, particularly in the Menu and Assignments area of the administrator, but we hope to start rolling out a CI Builds of Gantry 5 for WordPress soon.

We can’t wait to get the community started on testing Gantry 5 for WordPress.

Next Post

Previous Post

CI Builds with Travis

Gantry 5 + Travis

Today we are happy to introduce a new section in the Downloads area: CI Builds. The CI (Continuous Integration) Builds are intended for all of those interested in trying the very latest builds of Gantry 5.

If you already tried manually installing Gantry 5 on your development environment, you might have found it quite difficult: we agree with you. Most of the time you really just want to try the latest changes or, perhaps, verify that an issue has been truly resolved.

Thanks to Travis CI we are now able to automatically build installable packages that get generated everytime a new commit happens in the develop branch at the Gantry 5 repository.

The packages can be installed exactly like any Beta or RC, their version will be dev-<commit> (ie, dev-d6a989dea). The <commit> is the commit hash that has triggered the automatic build.

Worth noticing is also that in these packages you will find uncompressed assets (JS/CSS) with sourcemaps. This is different from a production release where there are no sourcemaps and the assets get minified.

It is STRONGLY advised NOT to install CI Builds in a production environment. Due to the nature of these builds, where everything gets generated automatically and is a mirror of the actual development repository, chances are that there will be bugs, issues and unexpected behaviors.

Next Post

Previous Post

Gantry 5 RC2 Released

Gantry 5 has taken another giant leap forward in its trek towards its first major stable release. Gantry 5 RC2 (Release Candidate 2) was released last Friday to positive review from our growing community. This release includes a multitude of bug fixes, as well as several additional features and enhancements that focus on making Gantry exceptionally user friendly.

Configurations Changed to Outlines

Gantry 5 RC2

Throughout the CMS world, the term Configurations is used to describe a number of different things. In Gantry, we used the term to describe a set of layout, style, assignments, and particle settings. This is a major component of the Gantry framework, and we wanted to make sure it was free of confusion, especially when the word configuration can be used in so many different ways.

Our solution: Renaming Configurations to Outlines. We found that by doing this, we eliminate a lot of the potential confusion caused by new users.

Menu Improvements

Gantry 5 RC2

Gantry 5’s powerful Menu Editor is a menu customization powerhouse. Taking the menu defined by your CMS and enabling you to customize it, inject module instances and particles, as well as to define how it is displayed on your site, makes it a valuable addition to the Gantry framework. In RC2, we added a number of features to make it even better.

Individual submenus can now have custom widths set. You can now set the width of a parent’s dropdown in rem, em, or px unit sizes, as well as auto which lets Gantry set the width of the dropdown automatically.

Individual menu items can now have CSS classes assigned to them. Previously, you were able to do this with injected module instances and particles, but now this functionality has been extended to CMS-provided menu items.

These features give you another level of control over your site’s menus.

Easier Saving of Changes

Gantry 5 RC2

Now, whenever you make changes to a particle, position, module instance, menu item, or virtually any other item, you have the option to Apply and Save your changes. This spares you the step of having to save your changes at the administrative panel level, making it easier to quickly change and check your changes.

For example, if you make a change to a particle in the Layout Manager, you can choose to have this change save immediately to the layout without having to save your layout, separately.

Gantry 5 RC2

The Actions Bar in the Styles, Settings, and Layout administrative panels has also been duplicated and added to the bottom of the page. You don’t have to scroll back to the top of the page to do things like save settings changes, load presets, and recompile CSS.

Layout Manager Improvements

Gantry 5 RC2

One of the improvements suggested most by our community was the option to switch between preset layouts while maintaining the particles which are in place. There is now an option in the Load tool within the Layout Manager that enables you to preserve particles.

These are just a handful of the additions made in RC2. If you haven’t already, please take a moment to take a look at Gantry 5 and try it for yourself. We have a free theme available called Hydrogen which you can use to check out these and many more features found in the all-new Gantry 5 framework.

Feel free to visit our project roadmap to learn more about Gantry 5 RC2, as well as plans for upcoming release(s) as development continues. You can also submit bug reports or feature addition suggestions on Github.

If you have any questions about Gantry 5 RC2, or would like to chat with other Gantry users, please visit our chat room on Gitter. You can also find detailed guides and tutorials in our documentation.

Next Post

Previous Post

Gantry 5 RC1 Released

Gantry 5 release candidate graphic

The RocketTheme development team has been hard at work getting Gantry 5 ready for prime time. After months of work by our small team, the Gantry 5 release candidate is now available on Github.

In late 2009, the open source Gantry framework was initially released to the public. Before Gantry, we found ourselves having to perform a lot of repetitive steps while creating new templates. A lot of our time was spent hand-coding the same features each month. We needed something simpler, and our solution was Gantry.

This framework would not only help us create powerful and flexible Joomla templates and WordPress themes, but also to empower a growing community of Joomla and WordPress developers that would benefit from using a framework that was easy to understand, yet powerful enough to meet the needs of their clients.

Fast-forward to 2015, and Gantry 5 is set to redefine what a theme can do.

A New Development Approach

Gantry 5 is a complete, ground-up rewrite of the Gantry framework. Taking advantage of the latest Web technologies, Gantry 5 is built for the needs of tomorrow’s websites, today.

We wanted to create a framework that benefited from years of user feedback we received from Gantry 1-4. By opening up our development process to the community on Github, and creating a chat room where beta testers and Gantry users could communicate with our team directly, we were able to take Gantry 5 to a level that wouldn’t have been possible before.

This is the first version of Gantry that is community driven, not just community inspired.

By shedding a lot of the weight that comes with maintaining backward compatibility through multiple major updates, we were able to create a slimmer, faster user experience. We added human-readable solutions such as YAML configuration and an all-new touch-friendly user interface. The Gantry 5 Administrator is simple to use with drag-and-drop functionality and no programming experience required.

A Better Way to Theme

It is easier than ever to create a unique, flexible theme with Gantry. Twig templating, YAML configuration, and integrated support for SCSS, LESS, and CSS are just a few of the ways Gantry 5 is set to make life easier for developers.

One major improvement is Gantry’s cross-platform capability. Traditionally, if you wanted to make a template for Joomla and WordPress, you would have to build it for each platform, with a lot of specific steps required for each one. Gantry 5 eliminates a lot of that by being independent of the content management system. We expect Gantry 5 to not only work with Joomla and WordPress, but also other content management systems such as phpBB, Magento, and flat-file platforms such as Grav.

Full disclosure: Grav is also made by members of the RocketTheme development team.

On the design end, a brand new Layout Manager and Menu Editor gives you the power to quickly assemble and style your site exactly as you need it to. The Style administrative panel enables you to adjust the style of your site in seconds.

For your end users, the ability to create simple-to-use Particles will give them the freedom to update information on their site without ever having to open a text editor or risk breaking the site’s code. Everything they need can be accessed from the administrator.

What’s Ahead?

Gantry 5 is continually being developed, and will receive regular updates and additional features well beyond the 5.0.0 release. Our Development Roadmap is constantly being updated with new features and plans for upcoming releases.

The Gantry 5 Release Candidate is not a stable release, and users should expect frequent updates with bug fixes and feature additions leading up to 5.0.0.

Gantry 4 is not going anywhere, either. Because Gantry 5 is not backward compatible, our team is dedicated to maintaining support for Gantry 4 in parallel with Gantry 5 for the foreseeable future on both Joomla and WordPress.

Where to Get Help

A chat room has been set up using Gitter where you can go to talk about the project with developers, contributors, and other members of the community. This is the best place to go to get quick tips and discuss features with others.

Documentation is also available, and being continually added to as development progresses. Is something missing? You can contribute to the documentation through GitHub.

Next Post

Previous Post