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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

Extending a Basic Site - fundamental errors?


Go to End


4 Posts   1628 Views

Avatar
mhdesign

Community Member, 216 Posts

11 December 2009 at 2:16pm

I'm calling it a fundamental error because I've probably made a fairly basic mistake but I can't see it... I want to add a 'news' type section to a site that I am building, as per the following tutorial:

http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site#creating_the_news_section_page_types

I have created the mysite/code/ArticlePage.php and mysite/code/ArticlePage.php pages, then gone on to create the themes/tutorial/templates/Layout/ArticlePage.ss and themes/tutorial/templates/Layout/ArticleHolder.ss pages. Thinking I can fine-tune these pages later and remove anything that I don't want, I have done a straight cut and paste from the tutorial. I have rebuilt the database http://localhost/dev/build?flush=1 - and as far as I can see, having read and re-read the tutorial, that should be it. Sure enough, the ArticleHolder and ArticlePage page types have appeared in the CMS. I have set the parent page type as 'ArticleHolder' and set up an 'ArticlePage' as a test.

However the parent 'ArticleHolder' page is not displaying the children pages?!

Have I missed something fairly basic?

Avatar
mhdesign

Community Member, 216 Posts

11 December 2009 at 2:25pm

OK, I've investigated further and found out that the sub-page DOES show in the list when I check the 'show in menus' box in the CMS. However I don't want these subpages to appear in the site navigation! If I had wanted them to appear in the navigation I wouldn't be setting up these pages as ArticleHolder is already a list of subpages! As I said, it's a very fundamental error! So can anybody offer a work-around here?

Avatar
Willr

Forum Moderator, 5523 Posts

11 December 2009 at 7:47pm

By default all control loops will filter for 'Show In Menus' if this is unticked it will hide them - as you have found out. The way to do this is to tick the box so that they aren't in the navigation but in the template use the control <% control AllChildren %> instead of <% control Children %> in your holder page. AllChildren ignores the show in menus.

Avatar
mhdesign

Community Member, 216 Posts

12 December 2009 at 1:31pm

To my rescue again Will! Reckon I owe you a beer or two -- thanks!!