如何获得自定义路线以显示在Google Sitemap中?

问题描述 投票:0回答:1

我们正在使用Google Sitemap模块:https://github.com/wilr/silverstripe-googlesitemaps

我们有一个TourPage.php,它在其控制器上具有自定义路由,在我们的sitemap.xml中,它可以很好地显示父页面,但没有显示路由:

例如,目前仅显示:

website.com/tours/tour-name-1/
website.com/tours/tour-name-2/

但我们希望它显示:

website.com/tours/tour-name-1/
website.com/tours/tour-name-1/photos
website.com/tours/tour-name-1/details
website.com/tours/tour-name-1/reviews

...

website.com/tours/tour-name-2/
website.com/tours/tour-name-2/photos
website.com/tours/tour-name-2/details
website.com/tours/tour-name-2/reviews

我们如何实现这一目标?

class TourPage_Controller extends Page_Controller {

    private static $allowed_actions = array('BrochureForm', 'brochure', 'brochure_thanks', 'details', 'photos', 'reviews', 'book', 'downloadItineraryFile', 'map', 'overview', 'getSlugName');

    public function photos() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        return array(
            'MetaTitle' => $this->resolveMetaTitle('MetaTitlePhotos'),
            'Photos' => $this->TourPhotos(),
            'MetaImage' => $this->resolveMetaImagePhotos(),
            'MetaVideo' => false,
            'ImageSlug' => $this->getSlugName(),
            'SluggedImage' => $this->getImageBySlug(),
            'AbsolutePhotoURL' => $this->getAbsolutePhotoURL()
        );
    }


    public function index() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        // Have to return something...
        return array();
    }

    public function init() {
        parent::init();
        if($this->request->param('Action') == 'brochure') {
            Requirements::themedCSS('bootstrap.min');
            Requirements::javascript(THIRD_PARTY_PATH . 'javascript/chosen.jquery.min.js');
        }
    }

    public function overview() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        return array();
    }

    public function details() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        // Have to return something...
        return array(
            'MetaTitle' => $this->resolveMetaTitle('MetaTitleDetails'),
            'Photos' => $this->TourPhotos(),
            'MetaImage' => $this->resolveMetaImageDetails(),
            'MetaVideo' => false
        );
    }


    public function reviews() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        return array(
            'MetaTitle' => $this->resolveMetaTitle('MetaTitleReviews'),
            'Reviews' => $this->data()->Reviews()->Filter('Disabled', 0),
            'MetaImage' => $this->resolveMetaImageReviews(),
            'MetaVideo' => false
        );
    }


    public function book() {
        // If we don't book, then head to the contact page
        if($this->ContactFormToBook) {
            FlashMessage::add('Please use the Contact Us form if you\'d like to book a ' . $this->Title, 'success');
            return $this->redirect(ContactPage::getFirstPageLink());
        }
        return $this->redirect(BookingPage::getFirstPageLink() . '?Tour=' . $this->ID);
    }

    /*
     * brochure page - with a check to ensure that they are allowed to view the page
     */
    public function brochure() {
        if(!$this->canViewPage()) {
            return $this->redirect(ToursPage::getFirstPageLink());
        }
        return array();
    }


    public function map(SS_HTTPRequest $request) {
        if(!$this->isAllowedMap()) {
            return $this->redirect($this->Link());
        }
        Requirements::javascript('https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&key=AIzaSyCNCBX_mLK0uuDElVttJVJgM2fuXIynv6E');
        Requirements::javascript(THIRD_PARTY_PATH . 'javascript/map.js');

        return array(
            'MetaImage' => $this->resolveMetaImageMap(),
            'MetaVideo' => false
        );
    }


}
silverstripe xml-sitemap
1个回答
1
投票

该模块提供了包括docs中所述的自定义路由的功能。

© www.soinside.com 2019 - 2024. All rights reserved.