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

[Solved] <% control AllChildren %> is displaying unpublished pages.


Go to End


2 Posts   1507 Views

Avatar
BigMoose

Community Member, 19 Posts

2 November 2011 at 10:30am

First, let me say I am REALLY new to all of this. Code and development is not my area of expertise. However, I have forced myself to learn in order to help out a family friend. My website is extremely close to being finished, but I am stuck on one snag.

I have, like many people here a drop-down styled menu. My menu only has two levels - the main one and the subpages. The client here likes how it looks, but there is one section in which she does not want to have the subpages appear in the drop-down menu. Reading other postings, the solution seems to be to use "Show in menus?" toggle in the cms.

This has led me to a new problem. The holder page, no longer shows the content I was retrieving from it's children pages. The solution for this seems to be to use the AllChildren control instead of just using Children since it will then 'see' these pages which are not meant to show in the menus.

That worked, but has also led me to a new and hopefully final problem with all of this. The problem is using the 'AllChildren' control is pulling information from all of the unpublished children pages too (orange highlighted pages in the cms). I can't have these unpublished pages appearing in the published site. Here is the code being used in my holder.ss file:

<div id="ContentContainer">
	<% include PageTitle %>
	
	
	<div id="OffreList">
		<% if AllChildren %>
		<p class="Normal">Below are the current positions available</p>	
		 <ul>
			<% control AllChildren %>
			<li>
				<p class="Title">$Title</p>
				<p class="Normal">$Content.FirstParagraph
					<a href="$Link">Information suppl&eacute;mentaire &gt;&gt;</a></p>
			</li>
			<% end_control %>
		</ul>
		<% else %>
			 $Content
			<p class="Normal">Désolé, il n'y a aucun emploi disponible en ce moment.</p>
		<% end_if %>	
	</div>
</div>

Again, I am like super-noob with everything here so please take that into consideration when responding. Any help would be greatly appreciated.

Avatar
BigMoose

Community Member, 19 Posts

2 November 2011 at 1:07pm

Okay, after puzzling this over for quite awhile now, the solution was to simply restart my computer. I am currently working on my local machine using MAMP, and I'm not sure why any of this happened. I decided to restart after I tried to add some new fields to my current page template, and it too was not functioning for me. I had tried performing the usual ?flush=1 and dev/build?flush=1. Neither of which made any difference at all. I don't know what this glitch I was experience was, but can this sort of thing happen when the page is posted to a web server?

Despite this odd behavior, as everything is working again I will mark this page as [solved].

Thanks to those who took the time to read my post. I'm glad that despite being a total code-noob my attempted code was proper after all.