Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix navbar #14

Merged
merged 1 commit into from
Aug 28, 2018
Merged

fix navbar #14

merged 1 commit into from
Aug 28, 2018

Conversation

elvisleung222
Copy link
Contributor

the sub-menus do not show up

the sub-menus do not show up
@osbre osbre mentioned this pull request Aug 12, 2018
@osbre
Copy link

osbre commented Aug 12, 2018

for this: #15

@daftspunk daftspunk merged commit c59580c into responsiv:master Aug 28, 2018
@daftspunk daftspunk mentioned this pull request Aug 28, 2018
@wing5wong
Copy link

wing5wong commented Aug 28, 2018

this change was not required.
Correct template was not pulled in by october before this commit.
The following works correctly (as the code was previously), but what was being pulled in shown below this working code

{# Note: Only one levels of sublinks are supported by Bootstrap 3 #}
{% set
    links = {
        'home': ['home', 'Home'],
        'pages': {
            name: 'Pages',
            sublinks: {
                'about':         ['samples/about', 'About Us'],
                'contact':       ['samples/contact', 'Contact Us'],
                'pricing-table': ['samples/pricing-table', 'Pricing Table'],
                'services':      ['samples/services', 'Services'],
                'signin':        ['samples/signin', 'Sign In'],
                'register':      ['samples/register', 'Register'],
                'error':         ['error', 'Error Page'],
                '404':           ['404', '404 Page'],
            },
        },
        'portfolio': {
            name: 'Portfolio',
            sublinks: {
                'portfolio': ['portfolio/portfolio', 'Portfolio'],
                'project': ['portfolio/project', 'Project'],
            },
        },
        'blog': {
            name: 'Blog',
            sublinks: {
                'blog': ['blog/blog', 'Blog'],
                'post': ['blog/post', 'Blog Post'],
            },
        },
        'shop': {
            name: 'Shop',
            sublinks: {
                'shop': ['shop/shop', 'Shop'],
                'product': ['shop/product', 'Product'],
                'cart': ['shop/cart', 'Cart'],
            },
        },
        'ui-elements': ['ui-elements', 'UI Elements'],

    }
%}

{% macro render_menu(links) %}
    {% import _self as subnav %}

    {% for code, link in links %}
        <li class="{{ code == currentPage ? 'active' }} {{ link.sublinks ? 'dropdown' }}">
            <a
                href="{{ link.sublinks ? '#' : (link.page ?: link[0])|page }}"
                {% if link.sublinks %}data-toggle="dropdown"{% endif %}
                class="{{ link.sublinks ? 'dropdown-toggle' }}"
            >
                {{ link.name ?: link[1] }}
                {% if link.sublinks %}<span class="caret"></span>{% endif %}
            </a>
            {% if link.sublinks %}
                <span class="dropdown-arrow"></span>
                <ul class="dropdown-menu">
                    {{ subnav.render_menu(link.sublinks) }}
                </ul>
            {% endif %}
        </li>
    {% endfor %}
{% endmacro %}

{% import _self as nav %}

<nav id="layout-nav" class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="fa fa-bars"></span>
            </button>
            <a class="navbar-brand" href="{{ 'home'|page }}">Flat</a>
        </div>
        <div class="collapse navbar-collapse navbar-main-collapse">
            <ul class="nav navbar-nav navbar-right">
                {{ nav.render_menu(links) }}
                <li>
                    <button
                        onclick="window.location='{{ 'samples/signin'|page }}'"
                        class="btn btn-sm navbar-btn btn-primary navbar-right hidden-sm hidden-xs">
                        Sign in
                    </button>
                </li>
            </ul>
        </div>
    </div>
</nav>

what was previously loaded in through october had {{ _self.render_menu(link.sublinks) }} instead of {{ subnav.render_menu(link.sublinks) }} and was missing the required import within the macro

{% macro render_menu(links) %}
    {% import _self as subnav %}

...

            {% if link.sublinks %}
                <span class="dropdown-arrow"></span>
                <ul class="dropdown-menu">
                    {{ subnav.render_menu(link.sublinks) }}
                </ul>
            {% endif %}

...

@daftspunk
Copy link
Member

daftspunk commented Aug 28, 2018

Can you do another PR to fix it? Or do we just have to roll it back?

@daftspunk daftspunk mentioned this pull request Aug 28, 2018
@wing5wong
Copy link

Revert should be fine.
I will test with October install and check if it pulls in the right code this time.

@wing5wong
Copy link

It is working now.
Cant explain why it was installing different code to what was originally in this repo, perhaps a prior commit.
Making the change, then reverting back has triggered october to install the correct, functioning code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants