3

I've searched these boards and haven't been able to find the answer to my specific question.

I'm working on building my navigation, and I want to build it in a structure. It will be a multi-level navigation, which is why it makes sense for a structure. However, I've already built a separate structure for a sermon catalog that I want to keep separate from the navigation structure.

Basically, I want to be able to link to a separate structure within my navigation structure. Is this possible? Is there a better way to do this that I haven't grasped yet?

Navigation Structure Example

1.Home

2.About

  • Directions
  • Staff

3.Watch (I want this to link to my sermon structure)

4.Kids & Students

  • Highschoolers
  • Middleschoolers
  • K-5th

EDIT: I've tried adding in an entry type to navigation and linking to the structure, but it won't let me link to the actual structure. Just entries inside the structure. Which is not what I want. Any thoughts?

3

I'll assume that 'watch' is a landing page in which you want to list out the various sermons from the sermons structure. In which case you can retrieve and display those in the 'watch' template using a for...in or a nav...in loop. For example:

{% set sermons = craft.entries.section('sermons').limit(null) %}
<ul>
    {% nav sermon in sermons %}
        <li><a href="{{ sermon.url }}">{{ sermon.title }}</a></li>
        {% if children %}
            {% children %}
        {% endif %}
    {% end for %}
</ul>

In your 'sermons' section settings you can then set the top-level uri to be:

watch/{slug}

And the nested uri to:

{parent.uri}/{slug}

In this way, you can set the uri's to match up nicely, with the index page as 'watch' and the sermon entries as 'watch/sermon-parent-slug/sermon-slug'

  • So I've already setup a "landing page" under /sermons with my sermon structure. I've got it looping through and displaying them already. I guess all I would need to od is change the top level uri of the sermon structure to be watch/{slug}? Am I reading that correctly? Edit: And then add that code to the /watch page? – misteroptimist Nov 17 '14 at 21:54
  • What I was suggesting is placing your sermons landing page in the navigation structure, since I assume that there is only one landing page which houses all sermons anyway. Then in your sermons structure the top level would be the actual sermons (with whatever subpages you need under those). The reason I suggest this is that by adding 'watch' to the navigation structure, craft is already creating the 'watch' uri anyway. Might as well use it, rather than creating some fancy routing workaround. – Douglas McDonald Nov 17 '14 at 22:03
  • A lot will depend on what actual uri you want (and or if there will ever be other things besides sermons that you want in the watch section). If you want 'watch/sermons/sermon-slug' and the top-level of your sermons structure is 'sermons' (with only 1). Then you could leave the index in the sermons template and pull that content (i.e. index) into the watch template (if that makes sense). – Douglas McDonald Nov 17 '14 at 22:16
  • Interesting. I understand what you are saying now. I think I'm just going to go with your initial suggestion. I'll move over the code on my sermons page to the watch page and just pull in all my information from my other structure. That makes the most sense to me right now. I suppose this could work the same for a channel? Say I wanted to add in a blog in the navigation. I'd just set that up as a separate channel and then pull it in same as I did the structure? It's all starting to make sense! – misteroptimist Nov 17 '14 at 22:30
  • 2
    For most of my projects (to date anyway), I tend to use a single structure (with unique Entry Types for each unique page layout) to house all of my 'one-off' and 'index' landing pages and to generate site navigation, and other structures or channels for repetitive content (i.e. blog, news, articles, projects, office locations, etc. — sermons in your case), which I can pull into the main 'pages' index templates (either as a list of links to the full entry or the actual content itself depending on the type of content it is). – Douglas McDonald Nov 17 '14 at 23:30

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.