Skip to content

Add (or Document) how to get the section list from the sitemap service #333

@tacman

Description

@tacman

Description

I'd like to inject the service into a controller so I can create the sitemap list by section.

Example

In the controller:

        // @todo: inject the SiteMap service and get the sections.
        $sections = [
            '',
            'default.',
            'blog.',
            'misc.',
            'yml.'
        ];
        return $this->render('default/index.html.twig', [
            'sections' => $sections,
            'pages' => $pageRepository->findBy([], [], 30)
        ]);
    <h3>Sitemaps</h3>
    <ul>
        {% for section in sections %}
            {% set url = '/sitemap.%sxml'|format(section) %}
            <li><a href="{{ url }}">
                    {{ url }}
                </a>
            </li>
        {% endfor %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions