Search code examples
umbracoumbraco7umbraco6

i want only published children in umbraco


I want only those children who are publish in content folder.

this is my below code:

<umbraco:Macro runat="server" language="cshtml">
                        @foreach (var item in Model.Children)
                          {
                                <h3 class="vacancyH">@item.jobTitle</h3>

                                <table class="vaccTbl">
                                <tr>
                                <td class="vaccDetailTitle">Salary &amp; Benefits:</td>
                                <td class="vaccDetailDesc">@item.salaryBenefits</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle">Employment Type:</td>
                                <td>@item.employmentType</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle">Department:</td>
                                <td>@item.department</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle">Report to Position:</td>
                                <td>@item.reportToPosition</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle">Location:</td>
                                <td>@item.location</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle">Date of Description:</td>
                                <td>@item.businessArea</td>
                                </tr>
                                <tr>
                                <td class="vaccDetailTitle" valign="top">Summary:</td>
                                <td class="tablep">@item.vacancySummary</td>
                                </tr>
                                <tr>
                                <td colspan="2" valign="middle"><img src="/images/wordicon.jpg" alt="" class="docIcon" /><a href="@item.fullJobDescription" class="vaccDoc">Download the Full Job Description</a></td>
                                </tr>
                                </table>
                                <div class="vaccCloseDate">Application Deadline: @item.applicationDeadline.ToString("dd MMMM yyyy")</div>
                                <div class="vaccApplyForPosition"><a href="/[email protected]">Click here to apply</a></div>

                          }
                    </umbraco:Macro>

By this i get the all children which are not published..

Now i want the only published children.


Solution

  • What do you mean by published? What you are doing will only display published items, this is how umbraco works. Using where("visible") relies on you having created a property on one of your doc types called umbracoNaviHide and setting it to true in order to hide items. If what you have is not working then there is another reason for it.

    Are your unpublished items greyed out in the content tree?

    Try right click in top level content node and republish entire site.

    Make sure your browser isn't caching something so clear the cache.

    Failing all this simply delete umbraco.config in your app_data folder.

    Umbraco does not render unpublished items.