Table of Contents

How to Integrate the basics

Okay now we've got your BlestaCMS Pro installed, it's time to add the integration code to your template. This is the easy and fun part because you add what you want to use. Flexible to your needs. If you want our recommend code simply scroll to the bottom of the page. We want to describe each section. Example: /app/views/client/bootstrap/structure.pdt

<?php
        Loader::loadModels($this, array("cmspro.Pages"));
?>

This is the core of the integration. The above allows just the pages to load so if you want to add more features add the models to the array like so:

<?php
        Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
?>

This loads up the Pages, Menu and Footer models. Now we need to add the code for each section we want:

<?php
	Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
    // Menu items
    if ($this->Html->ifSet($logged_in)) {
       	$client_group = $this->Menus->grabClientGroup($contact->client_id);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus($client_group);
    }else{
       	$menu_items = $this->Menus->getAllMenusAndSubmenus('0');
    }
?>

What we've done is added the Menus for Logged in or not. If we're logged in then it shows the menus for their client group.

<?php
	Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
    // Menu items
    if ($this->Html->ifSet($logged_in)) {
       	$client_group = $this->Menus->grabClientGroup($contact->client_id);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus($client_group);
    }else{
       	$menu_items = $this->Menus->getAllMenusAndSubmenus('0');
    }
    // Footer Links
    $footer_links = $this->Footer->getAllFooterLinks();
    $footer_categories = $this->Footer->getAllFooterCategories();
?>

Now we've added the Footer links and categories, these are used for the Footer links.

Multi-languages

<?php
	Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
    // Menu items
    if ($this->Html->ifSet($logged_in)) {
       	$client_group = $this->Menus->grabClientGroup($contact->client_id);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus($client_group);
    }else{
       	$menu_items = $this->Menus->getAllMenusAndSubmenus('0');
    }
    // Footer Links
    $footer_links = $this->Footer->getAllFooterLinks();
    $footer_categories = $this->Footer->getAllFooterCategories();
    // Multi-languages
    $lang = $this->Pages->getCurrentLang();
    $default_lang = $this->Pages->getAllLang()[0]->uri;
?>

We highly recommend that you use the languages because we use it in all our code.

Final code:

So what everyone should finally have if they wish to make the most out of the BlestaCMS Pro is as follows:

<?php
	Loader::loadModels($this, array("cmspro.Pages", "cmspro.Menus", "cmspro.Footer"));
    // Menu items
    if ($this->Html->ifSet($logged_in)) {
       	$client_group = $this->Menus->grabClientGroup($contact->client_id);
       	$menu_items = $this->Menus->getAllMenusAndSubmenus($client_group);
    }else{
       	$menu_items = $this->Menus->getAllMenusAndSubmenus('0');
    }
    // Footer Links
    $footer_links = $this->Footer->getAllFooterLinks();
    $footer_categories = $this->Footer->getAllFooterCategories();
    // Multi-languages
    $lang = $this->Pages->getCurrentLang();
    $default_lang = $this->Pages->getAllLang()[0]->uri;
?>

This is our final code to integrate the BlestaCMS Pro to your template.