So you would like to show the Blesta navigation so you don't need to incorporate it into your custom BlestaCMS Pro navigation, which is used for your template, we've all been there.

We use the following code and plenty of our Alpha testers have found it to work very well. This code only shows the Blesta navigation on the following pages:

  • https://yoursite.com/client/*
  • https://yoursite.com/client/login/
  • https://yoursite.com/client/reset/
  • https://yoursite.com/plugin/*
  • https://yoursite.com/order/*

The only page you may need to edit is the portal link to your "return to portal" link.

<?php
      if (strpos($_SERVER['REQUEST_URI'], "client") && $page_title != "Log In" && $page_title != "Reset Password" && $page_title != "Forgot Username" || strpos($_SERVER['REQUEST_URI'], "plugin")  || strpos($_SERVER['REQUEST_URI'], "order") !== false){
    ?>
        <div class="nav-content" style="margin-bottom: 15px;">
            <nav class="navbar navbar-expand-md navbar-dark">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#main-navbar">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse pb-2 pb-md-0" id="main-navbar">
                    <div class="container-md flex-column flex-md-row align-items-start">
                        <?php
                        $active_nav = null;
                        ?>
                        <ul class="navbar-nav">
                            <?php
                            foreach ($this->Html->ifSet($nav, []) as $link => $value) {
                                $attributes = ['class' => ['nav-item']];
                                $link_attributes = ['class' => ['nav-link']];
                                $dropdown = !empty($value['sub']);
                                $active = false;

                                if ($value['active']) {
                                    $active = true;
                                    $attributes['class'][] = 'active';
                                    $active_nav = $value;
                                }
                                if ($dropdown) {
                                    $attributes['class'][] = 'dropdown';
                                    $link_attributes['class'][] = 'dropdown-toggle';
                                    $link_attributes['data-toggle'][] = 'dropdown';

                                    // Set parent to active if child is
                                    if (!$active) {
                                        foreach ($this->Html->ifSet($value['sub'], []) as $sub_link => $sub_value) {
                                            if ($sub_value['active']) {
                                                $attributes['class'][] = 'active';
                                                break;
                                            }
                                        }
                                    }
                                }
                            ?>
                            <li<?php echo $this->Html->buildAttributes($attributes);?>>
                                <a href="<?php $this->Html->_($link);?>"<?php echo $this->Html->buildAttributes($link_attributes);?>>
                                    <i class="<?php $this->Html->_($value['icon']);?>"></i>
                                    <?php
                                    $this->Html->_($value['name']);
                                    ?>
                                </a>
                                <?php
                                if (!empty($value['sub'])) {
                                ?>
                                <div class="dropdown-menu">
                                    <?php
                                    foreach ($this->Html->ifSet($value['sub'], []) as $sub_link => $sub_value) {
                                    ?>
                                    <a class="dropdown-item" href="<?php $this->Html->_($sub_link);?>"><i class="<?php $this->Html->_($sub_value['icon']);?>"></i> <?php $this->Html->_($sub_value['name']);?></a>
                                    <?php
                                    }
                                    ?>
                                </div>
                                <?php
                                }
                                ?>
                            </li>
                            <?php
                            }
                            ?>
                        </ul>
                        <ul class="navbar-nav">
                            <?php
                            if ($this->Html->ifSet($logged_in)) {
                            ?>
                            <li class="nav-item dropdown">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
                                    <?php $this->Html->_($contact->first_name);?> <?php $this->Html->_($contact->last_name);?>
                                    <b class="caret"></b>
                                </a>
                                <div class="dropdown-menu">
                                    <a class="dropdown-item" href="<?php echo $this->Html->safe($this->client_uri . 'main/edit/');?>"><?php $this->_('AppController.client_structure.text_update_account');?></a>
                                    <div class="dropdown-divider"></div>
                                    <a class="dropdown-item" href="//<?php echo $this->Html->safe($this->Html->ifSet($system_company->hostname));echo $this->Html->safe(WEBDIR); ?>portal"><?php $this->_('AppController.client_structure.text_return_to_portal');?></a>
                                    <div class="dropdown-divider"></div>
                                    <a class="dropdown-item" href="<?php echo $this->Html->safe($this->client_uri . 'logout/');?>"><?php $this->_('AppController.client_structure.text_logout');?></a>
                                </div>
                            </li>
                            <?php
                            } else {
                            ?>
                            <li class="nav-item">
                                <a class="nav-link" href="<?php echo $this->Html->safe($this->client_uri . 'login/');?>">
                                    <?php $this->_('AppController.client_structure.text_login');?>
                                </a>
                            </li>
                            <?php
                            }
                            ?>
                        </ul>
                    </div>
                </div>
            </nav>
        </div>
      <?php
        }
      ?>