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.

Template Questions

Extending a Basic Site - fundamental errors?


Reply

4 Posts   1083 Views

Avatar
arthurdent

11 December 2009 at 2:16pm Community Member, 166 Posts

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:

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

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
arthurdent

11 December 2009 at 2:25pm Community Member, 166 Posts

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

11 December 2009 at 7:47pm Forum Moderator, 5511 Posts

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
arthurdent

12 December 2009 at 1:31pm Community Member, 166 Posts

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