Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[Solved] How to hide subpages of type ArticlePage from Tutorial 2


Go to End


5 Posts   790 Views

Avatar
Mike Waters

Community Member, 6 Posts

22 March 2012 at 3:41pm

I have used the very good Tutorial 2 - extending a basic site to create a table of summaries of sub pages in the same way as the tutorial shows a list of articles. However I want to make the sub pages inaccessible to site visitors as all the information I want to show is in the table of summaries.

Is there a way of doing this? Unpublishing the sub-pages removes them from the table.

I hope this makes sense. Referring to the tutorial I want to hide all the pages of type ArticlePage and only show ArticleHolder.

thanks in advance!

Avatar
nimesodelta

Community Member, 22 Posts

23 March 2012 at 10:35am

Does

// in ArticlePage
static $defaults = array(
'ShowInMenus' => 0
);

help?

Avatar
Mike Waters

Community Member, 6 Posts

23 March 2012 at 3:04pm

Thanks for this nimesodelta - but I already have that in my code to prevent the subpages appearing in the menus.

What I am wanting is for the pages to be inaccessible - that is return a 404 page if access is attempted.

I want the content to appear in the parent page (ArticleHolder) only.

is this possible?

thanks

-Mike

Avatar
nimesodelta

Community Member, 22 Posts

23 March 2012 at 3:33pm

How about...

function index(){
$this->httpError(404);
}

Avatar
Mike Waters

Community Member, 6 Posts

23 March 2012 at 4:28pm

Thanks for the pointer - and the quick response!

The code you posted gave me function not found error, but the following worked for me

in ArticlePage.php:

    function index(){
        $errorPage = DataObject::get_one('ErrorPage');
        Director::redirect($errorPage->Link(),404);
    }