Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » [Solved] <% control AllChildren %> is displaying unpublished pages.

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

Page: 1
Go to End
Author Topic: 691 Views
  • BigMoose
    Avatar
    Community Member
    19 Posts

    [Solved] <% control AllChildren %> is displaying unpublished pages. Link to this post

    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.

  • BigMoose
    Avatar
    Community Member
    19 Posts

    Re: [Solved] <% control AllChildren %> is displaying unpublished pages. Link to this post

    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.

    691 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.