1

I've been trying to get the homepage to show up in the navigation...

What I'd like to display is the following...

<ul>
  <li class="nav-item active">                                    
    <a class="nav-link" href="/">About</a>
  </li>
  <li class="nav-item">                                    
    <a class="nav-link" href="/schedule">Schedule</a>
  </li>
  <li class="nav-item">                                    
    <a class="nav-link" href="/media">Media</a>
  </li>
  <li class="nav-item">                                    
    <a class="nav-link" href="/contact">Contact</a>
  </li>
</ul>

The following works to create the last 3 pages, but the homepage (about) does not seem to create.

<ul>
  {% set entries = craft.entries.section('page').find() %}
  {% nav navItem in entries %}
  <li class="nav-item{{ navItem.id == entry.id ? ' active' }}">                                    
    <a class="nav-link" href="{{ navItem.url }}">{{ navItem.title }}</a>
  </li>
  {% endnav %}
</ul>

The following works for a semi-dynamic homepage... however the name does not create... (If they change the title of the homepage on the backend, I'd like it to switch on the front-end.

<li class="nav-item{{ craft.request.firstSegment == "" ? ' active' }}">
  <a class="nav-link" href="/">{{ craft.entries.slug('_home_').entry.title }}</a>
</li>

Could anyone with a bit more experience with this give me some insight? I'm confused outta my mind.

1

I was able to figure out how to get this working...See the following..

{% set entries = craft.entries.section('homepage, page').find() %}
{% nav navItem in entries %}
<li class="nav-item{{ navItem.id == entry.id ? ' active' }}">                                    
  <a class="nav-link" href="{{ navItem.uri }}">{{ navItem.title }}</a>
</li>
{% endnav %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.