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.

General Questions /

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

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

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


Go to End
Reply


5 Posts   644 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, 21 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, 21 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);
    }