SilverStripe 3.1+动态创建页面重定向


SilverStripe 3.1+ Dynamically creating page redirects

我有一个页面类型为"ProductPage",它有一些选项卡可以导航到如下位置:

/ProductPageUrlSegment/?tab=视频

/ProductPageUrlSegment/?tab=音频

/ProductPageUrlSegment/?tab=照片

我希望在创建每个新产品页面时创建重定向,这样,如果您浏览/ProductPageUrlSegment/video,它就会转到/productPageUrlSe分段/?tab=视频

并且对于所有选项卡都是相同的。我不清楚我是否应该使用路由https://docs.silverstripe.org/en/3.3/developer_guides/controllers/routing/或重定向https://docs.silverstripe.org/en/3.3/developer_guides/controllers/redirection/

我有另一个项目的链接功能,它转到父页面

public function Link() {
    return $this->Parent()->Link() . '#' . $this->URLSegment;
}

我的大概是:

public function LinkVideo() {
    return $this->Link()->'/?=video' . '#' . $this->URLSegment->'/video';
}

我不知道如何解决这个问题,所以任何指导都很感激。

这将实现上述目的,方法是将URL作为一个操作进行处理,然后重定向到同一页面,但使用get变量集。。。

class ProductPage extends Page {
}
class ProductPage_Controller extends Page_Controller {
    private static $allowed_actions = array(
        'video',
        'audio',
        'photos',
    );
    public function video() {
         $this->redirect($this->Link().'?tab=video');
    }
    public function audio() {
        $this->redirect($this->Link().'?tab=audio');
    }
    public function photos() {
        $this->redirect($this->Link().'?tab=photos');
    }
}