Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Stop a page in the SiteTree from being viewable on front end

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 309 Views
  • nekranox
    Avatar
    Community Member
    31 Posts

    Stop a page in the SiteTree from being viewable on front end Link to this post

    Hey guys,

    I have a page which loads content from a series of child pages. I've set the child pages to hidden so they don't appear in the menu or sitemap. But I want to stop them from dispalying if you go direct to the URL of the child page.

    I've tried 301 redirects using the Link Mapping module and also via .htaccess but neither seem to override the CMS functionality.

    Is there anything I can put in the controller or page class to stop it from being displayed on the front end when requrested.

    Thanks,

    Robbie

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Stop a page in the SiteTree from being viewable on front end Link to this post

    Just create a 301 redirect in the init() method for the controller. Init is run everytime the controller is used. For instance, the below will redirect to the parent page.

    class SomeHiddenPage_Controller extends Page_Controller {
       
       function init() {
          $this->redirect($this->failover->Parent()->Link());

          parent::init();
       }
    }

    309 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.