prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
355 stars 102 forks source link

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

Open tacman opened 8 months ago

tacman commented 8 months ago

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 %}
tacman commented 8 months ago

I'm looking and upgrading and integrating https://github.com/miisieq/RobotsTxtBundle in order to generate a robots.txt file #330

It looks like most robots.txt file have a list of sitemap: keys, not just a single one. Is there a way to automatically generate that list from the sections?