MWDelaney / sage-bootstrap4-navwalker

MIT License
73 stars 34 forks source link

Stuck at getting started; help is appreciated! #1

Closed scallemang closed 6 years ago

scallemang commented 6 years ago

Hey there,

Working through the Theme Development w/ Sage book which mentions this code. I don't have much history with Composer or Sage, so forgive me if this is a dumb error: I'm trying to get started with this walker and it's erroring out, per the screenshot. I ran the composer command and can confirm that the library was successfully installed to vendor. Any idea what I'm doing wrong? Did I miss some interstitial step? Thanks in advance!

(I'm using Trellis and Bedrock (for the first time), in case that's relevant.)

screen shot 2018-02-13 at 11 04 02 am

MWDelaney commented 6 years ago

Hi! Sorry for the trouble you're having here. Can you post the content of your header.blade.php? Whatever Blade doesn't like is in there and I'll need to see it to better understand the issue.

scallemang commented 6 years ago

Happy to! Thanks in advance.

<header class="banner">
  <div class="container">
    <a class="brand" href="{{ home_url('/') }}">{{ get_bloginfo('name', 'display') }}</a>
    <nav class="nav-primary">
      @if (has_nav_menu('primary_navigation'))
        {!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav', 'walker' => new wp_bootstrap4_navwalker()]) !!}
      @endif
    </nav>
  </div>
</header>
MWDelaney commented 6 years ago

Gotcha. Try using this instead:

@if (has_nav_menu('primary_navigation'))
  {!! wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav', 'walker' => new \App\wp_bootstrap4_navwalker()]) !!}
@endif

The documentation assumes (unfairly) that you're setting up your wp_nav_menu() options in a Controller. I'll fix the docs! Thank you!

scallemang commented 6 years ago

@MWDelaney Perfect, thank you so much.

(Working with Sage is my first experience in namespacing to this degree, so I'm obviously still learning how it actually works, though I've been able to usually hack my way around it, haha. But I can see that I should read up on it till I fully grok how to work with it.)

Thanks again!

MWDelaney commented 6 years ago

No problem. Thanks for helping beef up the documentation!