src/controllers/SettingsController.php
public function actionIndex(): craft\web\Response
    {
        $this->requireLogin();

        $routeParameters = Craft::$app->getUrlManager()->getRouteParams();

        $source = (isset($routeParameters['source'])?$routeParameters['source']:'CpSection');


        // $allSections = Craft::$app->getSections()->getAllSections();
        $allSections = $this->_createEntrySectionQuery()->all();
        $allStructures = [];

        if (is_array($allSections)) {
            foreach ($allSections as $section) {
                $allStructures[] = [
                    'id' => $section['id'],
                    'type' => $section['type'],
                    'heading' => $section['name'],
                    'enabled' => ($section['sitemapEntryId'] > 0 ? true : false),
                    'elementCount' => $section['elementCount'],
                    'changefreq' => ($section['sitemapEntryId'] > 0 ? $section['changefreq'] : 'weekly'),
                    'priority' => ($section['sitemapEntryId'] > 0 ? $section['priority'] : 0.5),
                ];
            }
        }

        $allCategories = $this->_createCategoryQuery()->all();
        $allCategoryStructures = [];
        if (is_array($allCategories)) {
            // print_r($allSections);
            foreach ($allCategories as $category) {
                $allCategoryStructures[] = [
                    'id' => $category['id'],
                    'type' => 'category',
                    'heading' => $category['name'],
                    'enabled' => ($category['sitemapEntryId'] > 0 ? true : false),
                    'elementCount' => $category['elementCount'],
                    'changefreq' => ($category['sitemapEntryId'] > 0 ? $category['changefreq'] : 'weekly'),
                    'priority' => ($category['sitemapEntryId'] > 0 ? $category['priority'] : 0.5),
                ];
            }
        }
        $variables = [
            'settings' => Sitemap::$plugin->getSettings(),
            'source' => $source,
            'pathPrefix' => ($source == 'CpSettings' ? 'settings/': ''),
            'allStructures' => $allStructures,
            'allCategories' => $allCategoryStructures
            // 'allRedirects' => $allRedirects
        ];

        return $this->renderTemplate('sitemap/settings', $variables);
    }
public function actionIndex(): craft\web\Response
    {
        $this->requireLogin();

        $routeParameters = Craft::$app->getUrlManager()->getRouteParams();

        $source = (isset($routeParameters['source'])?$routeParameters['source']:'CpSection');


        // $allSections = Craft::$app->getSections()->getAllSections();
        $allSections = $this->_createEntrySectionQuery()->all();
        $allStructures = [];

        if (is_array($allSections)) {
            foreach ($allSections as $section) {
                $allStructures[] = [
                    'id' => $section['id'],
                    'type' => $section['type'],
                    'heading' => $section['name'],
                    'enabled' => ($section['sitemapEntryId'] > 0 ? true : false),
                    'elementCount' => $section['elementCount'],
                    'changefreq' => ($section['sitemapEntryId'] > 0 ? $section['changefreq'] : 'weekly'),
                    'priority' => ($section['sitemapEntryId'] > 0 ? $section['priority'] : 0.5),
                ];
            }
        }

        $allCategories = $this->_createCategoryQuery()->all();
        $allCategoryStructures = [];
        if (is_array($allCategories)) {
            // print_r($allSections);
            foreach ($allCategories as $category) {
                $allCategoryStructures[] = [
                    'id' => $category['id'],
                    'type' => 'category',
                    'heading' => $category['name'],
                    'enabled' => ($category['sitemapEntryId'] > 0 ? true : false),
                    'elementCount' => $category['elementCount'],
                    'changefreq' => ($category['sitemapEntryId'] > 0 ? $category['changefreq'] : 'weekly'),
                    'priority' => ($category['sitemapEntryId'] > 0 ? $category['priority'] : 0.5),
                ];
            }
        }
        $variables = [
            'settings' => Sitemap::$plugin->getSettings(),
            'source' => $source,
            'pathPrefix' => ($source == 'CpSettings' ? 'settings/': ''),
            'allStructures' => $allStructures,
            'allCategories' => $allCategoryStructures
            // 'allRedirects' => $allRedirects
        ];

        return $this->renderTemplate('sitemap/settings', $variables);
    }
public function actionIndex ( ) : craft \ web \ Response { $ this -> requireLogin ( ) ; $ routeParameters = Craft :: $ app -> getUrlManager ( ) -> getRouteParams ( ) ; $ source = ( isset ( $ routeParameters [ 'source' ] ) ? $ routeParameters [ 'source' ] : 'CpSection' ) ; // $allSections = Craft::$app->getSections()->getAllSections(); $ allSections = $ this -> _createEntrySectionQuery ( ) -> all ( ) ; $ allStructures = [ ] ; if ( is_array ( $ allSections ) ) { foreach ( $ allSections as $ section ) { $ allStructures [ ] = [ 'id' => $ section [ 'id' ] , 'type' => $ section [ 'type' ] , 'heading' => $ section [ 'name' ] , 'enabled' => ( $ section [ 'sitemapEntryId' ] > 0 ? true : false ) , 'elementCount' => $ section [ 'elementCount' ] , 'changefreq' => ( $ section [ 'sitemapEntryId' ] > 0 ? $ section [ 'changefreq' ] : 'weekly' ) , 'priority' => ( $ section [ 'sitemapEntryId' ] > 0 ? $ section [ 'priority' ] : 0.5 ) , ] ; } } $ allCategories = $ this -> _createCategoryQuery ( ) -> all ( ) ; $ allCategoryStructures = [ ] ; if ( is_array ( $ allCategories ) ) { // print_r($allSections); foreach ( $ allCategories as $ category ) { $ allCategoryStructures [ ] = [ 'id' => $ category [ 'id' ] , 'type' => 'category' , 'heading' => $ category [ 'name' ] , 'enabled' => ( $ category [ 'sitemapEntryId' ] > 0 ? true : false ) , 'elementCount' => $ category [ 'elementCount' ] , 'changefreq' => ( $ category [ 'sitemapEntryId' ] > 0 ? $ category [ 'changefreq' ] : 'weekly' ) , 'priority' => ( $ category [ 'sitemapEntryId' ] > 0 ? $ category [ 'priority' ] : 0.5 ) , ] ; } } $ variables = [ 'settings' => Sitemap :: $ plugin -> getSettings ( ) , 'source' => $ source , 'pathPrefix' => ( $ source == 'CpSettings' ? 'settings/' : '' ) , 'allStructures' => $ allStructures , 'allCategories' => $ allCategoryStructures // 'allRedirects' => $allRedirects ] ; return $ this -> renderTemplate ( 'sitemap/settings' , $ variables ) ; }
Handle a request going to our plugin's index action URL,
e.g.: actions/sitemap/default

@return mixed
Handle a request going to our plugin s index action URL e . g . : actions / sitemap / default