2

I'm currently working on our new Docs website. This site should hold the documentation for all our projects.

I thought I could structurize the content like this:

Project 1 (<-- Section)
    Project section header 1 (<-- Structure)
        Menu item 1.1
        Menu item 1.2
        Menu item 1.3
        Menu item 1.4
        Menu item 1.5
    Project section header 2
        Menu item 2.1
        Menu item 2.2
        Menu item 2.3

Project 2 (<-- Section)
    Project section header 1 (<-- Structure for Project 2)
        Menu item 1.1
        Menu item 1.2
        Menu item 1.3
        Menu item 1.4
        Menu item 1.5
    Project section header 2
        Menu item 2.1
        Menu item 2.2
        Menu item 2.3

I'd also like to have a dropdown which should list all available projects (Project 1, Project 2, ... from the above sample). If the visitor selects his desired project, a menu tree should be rendered in the sidebar with the corresponding structure.

Is this the right way?

2

Welcome to the Craft community. You try to create a new section for each project - right? In my opinion this is only necessary if you need different view and edit rights on each project. If you'r creating a "open for all" project documentation tool (open means for only one user group), than i would go with a single section. It's much easier to manage and starting with a new project. I would use two entry types in the section (https://craftcms.com/docs/sections-and-entries#entry-types). One entry type is for the project and one is for your chapters and the content.

    Example:
    1x Section called "projects"
        1x entry type called "project" with following fields (example)
            - name 
            - project description (rich text field)
            - project team (user field)
            - release date (table field with date and description)
            - ...

        1x entry type called "chapter" with following fields (example)
            - name/title
            - content (richt text field)
            - images (file field)
            - documents (file field)
            - ...

    Finaly you "project" section would be like this:
    Project 1 (entry type "project")
        - Chapter 1 (entry type "chapter")
           - Chapter 1.1 (entry type "chapter")
           - Chapter 1.2 (entry type "chapter")
        - Chapter 2 (entry type "chapter")
           - Chapter 2.1 (entry type "chapter")
           - ...
        - Chapter ...    

    Project 2 (entry type "project")
        - Chapter 1 (entry type "chapter")
           - ...      

For creating the dropdown-navigation, you can simple use the nav tag (https://craftcms.com/docs/templating/nav). Instead of a use option tags for output:

{% set entries = craft.entries.section('projects').level(1) %}

<select id="nav" onchange="if (this.value) window.location.href=this.value">
    {% nav entry in entries %}
        <option value="{{ entry.url }}">{{ entry.title }}</option>
    {% endnav %}
</select>

For the subnavigation you could take a look on this Craft recipe -> https://craftcookbook.net/recipes/fully-dynamic-hierarchical-nav-menu-template.

Other solutions: Depending on how many content is used in each chapter, you could also make use of a matrix fields for your content...

Doe's this make sense for you?

| improve this answer | |
  • This makes alot of sense for me! Thank you very much! This answers all I need! – Martin Gartner May 22 '17 at 17:05
  • Just implemented your suggestions and it works like a a charm! – Martin Gartner May 22 '17 at 17:59

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.