Essential: moving navigation bar items

Essential: moving navigation bar items

by Alessandro Nisticò -
Number of replies: 11

Hi

I am using Moodle 3.04 and theme Essential 3.0.1.2. I wonder if there is a way to move the items in the navigation bar as follows:

- move the custom menu to the header section, above the logo, aligned to the right;

- keep the language menu and the login button in the navigation bar, in this order, aligned to the right.

I found this post:

https://moodle.org/mod/forum/discuss.php?d=251744

which provides some hints that, however, probably don't apply to this version of the theme. I can't find essential/renderers/core_renderer.php.

Thanks in advance for any help.

Alessandro


Average of ratings: -
In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
In reply to Gareth J Barnard

Re: Essential: moving navigation bar items

by Alessandro Nisticò -

Thanks. I managed to move the language menu to the right, as I wanted.

I tried to move the custom menu to the header area editing header.php, adding the lines that generate the menu to the header div, but the menu doesn't display correctly. Any suggestion?

Thanks again

Alessandro


In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Alessandro,

Tricky.  Essential is a complex theme that takes time to understand.  This would take time to figure out.  Therefore I'd look at it for you but would need to be paid for my time.

Kind regards,

Gareth

In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Ciao Alessandro.

Could you please copy/paste the code you changed so that I can see what you are trying to achieve?

Thanks

Mary

In reply to Mary Evans

Re: Essential: moving navigation bar items

by Alessandro Nisticò -

Hi Mary, you can see what I would like to achieve in the attached picture. Navigation bar was easy to adjust. To move the custom menu into the header area, I made two changes in header.php as follows:


<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>;.

/**
 * Essential is a clean and customizable theme.
 *
 * @package     theme_essential
 * @copyright   2016 Gareth J Barnard
 * @copyright   2014 Gareth J Barnard, David Bezemer
 * @copyright   2013 Julian Ridden
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

require_once(\theme_essential\toolbox::get_tile_file('pagesettings'));

echo $OUTPUT->doctype();
?>
<html <?php echo $OUTPUT->htmlattributes(); ?> class="no-js">
<head>
    <title><?php echo $OUTPUT->page_title(); ?></title>
    <link rel="shortcut icon" href="<?php echo $OUTPUT->favicon(); ?>"/>
    <?php
    echo \theme_essential\toolbox::get_csswww();
    echo $OUTPUT->standard_head_html();
    ?>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Google web fonts -->
    <?php require_once(\theme_essential\toolbox::get_tile_file('fonts')); ?>
    <!-- iOS Homescreen Icons -->
    <?php require_once(\theme_essential\toolbox::get_tile_file('iosicons')); ?>
    <!-- Start Analytics -->
    <?php require_once(\theme_essential\toolbox::get_tile_file('analytics')); ?>
    <!-- End Analytics -->
</head>

<body <?php echo $OUTPUT->body_attributes($bodyclasses); ?>>

<?php echo $OUTPUT->standard_top_of_body_html(); ?>

<header role="banner">
<?php
if (!$oldnavbar) {
    require_once(\theme_essential\toolbox::get_tile_file('navbar'));
}
?>

CHANGES HERE

    <nav id="page-header" class="clearfix<?php echo ($oldnavbar) ? ' oldnavbar' : ''; echo ($haslogo) ? ' logo' : ' nologo'; ?>">
      <div class="navbar">
       

END CHANGES

    <div class="container-fluid">
            <div class="row-fluid">
                <!-- HEADER: LOGO AREA -->
                <div class="<?php echo (!$left) ? 'pull-right' : 'pull-left'; ?>">
<?php
if (!$haslogo) {
    $usesiteicon = \theme_essential\toolbox::get_setting('usesiteicon');
    $headertitle = $OUTPUT->get_title('header');
    if ($usesiteicon || $headertitle) {
        echo '<a class="textlogo" h<div class="navbar">ref="';
        echo preg_replace("(https?smile", "", $CFG->wwwroot);
        echo '">';
        if ($usesiteicon) {
            echo '<span id="headerlogo" aria-hidden="true" class="fa fa-'.\theme_essential\toolbox::get_setting('siteicon').'"></span>';
        }
        if ($headertitle) {
            echo '<div class="titlearea">'.$headertitle.'</div>';
        }
        echo '</a>';
    }
} else {
    echo '<a class="logo" href="'.preg_replace("(https?smile", "", $CFG->wwwroot).'" title="'.get_string('home').'"></a>';
}
?>

CHANGES HERE


<div class="custommenus pull-right">
<div id='essentialmenus' class="nav-collapse collapse pull-right">
    <div id="custom_menu">
        <?php echo $OUTPUT->custom_menu(); ?>
    </div>
    <div id="custom_menu_activitystream">
        <?php echo $OUTPUT->custom_menu_activitystream(); ?>
    </div>
</div>
</div>

END CHANGES

                </div>
                <?php if ($hassocialnetworks || $hasmobileapps) { ?>
                <a class="btn btn-icon collapsed" data-toggle="collapse" data-target="#essentialicons">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </a>

                <div id='essentialicons' class="collapse pull-<?php echo ($left) ? 'right' : 'left'; ?>">
<?php
}
// If true, displays the heading and available social links; displays nothing if false.
if ($hassocialnetworks) {
?>
                        <div class="pull-<?php echo ($left) ? 'right' : 'left'; ?>" id="socialnetworks">
                            <p id="socialheading"><?php echo get_string('socialnetworks', 'theme_essential') ?></p>
                            <ul class="socials unstyled">
                                <?php
                                echo $OUTPUT->render_social_network('googleplus');
                                echo $OUTPUT->render_social_network('twitter');
                                echo $OUTPUT->render_social_network('facebook');
                                echo $OUTPUT->render_social_network('linkedin');
                                echo $OUTPUT->render_social_network('youtube');
                                echo $OUTPUT->render_social_network('flickr');
                                echo $OUTPUT->render_social_network('pinterest');
                                echo $OUTPUT->render_social_network('instagram');
                                echo $OUTPUT->render_social_network('vk');
                                echo $OUTPUT->render_social_network('skype');
                                echo $OUTPUT->render_social_network('website');
                                ?>
                            </ul>
                        </div>
                    <?php
}
                    // If true, displays the heading and available social links; displays nothing if false.
if ($hasmobileapps) { ?>
                        <div class="pull-<?php echo ($left) ? 'right' : 'left'; ?>" id="mobileapps">
                            <p id="socialheading"><?php echo get_string('mobileappsheading', 'theme_essential') ?></p>
                            <ul class="socials unstyled">
                                <?php
                                echo $OUTPUT->render_social_network('ios');
                                echo $OUTPUT->render_social_network('android');
                                echo $OUTPUT->render_social_network('winphone');
                                echo $OUTPUT->render_social_network('windows');
                                ?>
                            </ul>
                        </div>
                    <?php
}
if ($hassocialnetworks || $hasmobileapps) {
?>
                </div>
<?php
}
?>
            </div>
        </div>
      </div>
    </div>
<?php
if ($oldnavbar) {
    require_once(\theme_essential\toolbox::get_tile_file('navbar'));
}
?>
</header>


Quite surprisingly smile it almost works. Problems are:

- the logo background changed to the navbar background, which I didn't want;

- the custom menu is left-aligned;

- there are a few changes that I would like to make, like vertically aligning the custom menu to the middle and adjusting fonts, that I am unable to make because not knowing well the complex css I am not sure where to write the code.

Thanks

Alessandro





Attachment layout.jpg
In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

OK I got that.

Just tell me what settings you have at the moment.

Are you using the OLD Navbar?

Thanks

Mary

In reply to Mary Evans

Re: Essential: moving navigation bar items

by Alessandro Nisticò -

No, I am using the default option (Navbar above the header)

Alessandro

In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

I am sorry...I cannot get this to work. The code you posted has errors in it which did not help, but even so there are multiple problems with the files.

The simplest way would be to write your own navbar.php and header.php based on your specific needs.

The code generally in those two files is too much with all those settings. It's not so much hard to do but complicated finding your way round. Its a bit like a tangle of wool, where you can see one end of the length of wool but cannot find the other because it is all knotted together!

Sadly I had to accept defeat!

I am so sorry

Mary

In reply to Mary Evans

Re: Essential: moving navigation bar items

by Alessandro Nisticò -

Don't worry, I knew it was not simple. I will keep you informed if I make any progress.

Thanks

Alessandro


In reply to Alessandro Nisticò

Re: Essential: moving navigation bar items

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

This is a simplified version of the header.php which works but it does cut out all the extra settings like social icons etc.

See attacher header.php

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Essential: moving navigation bar items

by Alessandro Nisticò -

Sorry for the late reply. I think it's a very good starting point. Thanks a lot!

Alessandro