21285 Posts in 5732 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » [Solved] How to hide subpages of type ArticlePage from Tutorial 2
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 216 Views |
-
[Solved] How to hide subpages of type ArticlePage from Tutorial 2

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!
-
Re: [Solved] How to hide subpages of type ArticlePage from Tutorial 2

23 March 2012 at 10:35am
Does
// in ArticlePage
static $defaults = array(
'ShowInMenus' => 0
);help?
-
Re: [Solved] How to hide subpages of type ArticlePage from Tutorial 2

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
-
Re: [Solved] How to hide subpages of type ArticlePage from Tutorial 2

23 March 2012 at 3:33pm
How about...
function index(){
$this->httpError(404);
} -
Re: [Solved] How to hide subpages of type ArticlePage from Tutorial 2

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);
}
| 216 Views | ||
|
Page:
1
|
Go to Top |

