Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using a page layout to style some content pages on my Sharepoint 2010 public facing website. On this specific page layout I need to add something which is only visible from the third level of subsites, this meaning this level: http://www.website.com/subsite1/subsubsite1/pages/default.aspx

When a user is on this level, sitename subsubsite1, he/she needs to see a server control. Is there a way I can do such a thing, without needing to code something. I create a webpart which could do such a thing, but that's not a preferred option.

I'll try to make this a bit more concrete with an example. The thing I need to add is an asp:Repeater which contains several menu items of the next level of subsites. The reason we use an asp:Repeater for it is because the default sharepoint:Menu screws up our html (there'a a table wrapper around the menu), also we've got a bit more control on the created html when using this repeater.

The page layout looks like this:

<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
    <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
    <div id="left_content_container_big" class="global_settings_containers">
        <div id="top_shadow" class="global_settings_containers">
        </div>
        <div id="middle_shadow" class="global_settings_containers">
            <div id="left_content_big">             
                <div class="left_content_big_menu">
                    <div id="sub_submenu" class="">
                        <asp:Repeater ID="SubMenuLevel3" runat="server" DataSourceID="cjgSiteMapLevel3">
                            <HeaderTemplate><ul id="sub_submenu_ul" class=""></HeaderTemplate>
                            <ItemTemplate><li><a href="<%# Eval("Url")%>" class="" >
                                                <%# Eval("Title")%></a></li></ItemTemplate>
                            <FooterTemplate></ul></FooterTemplate>
                        </asp:Repeater>
                    </div>
                    <asp:SiteMapDataSource
                        ShowStartingNode="false"
                        SiteMapProvider="CurrentNavSiteMapProvider"
                        EnableViewState="true"
                        StartFromCurrentNode="false"
                        StartingNodeOffset="2"
                        id="cjgSiteMapLevel3"
                        runat="server"/>
                </div>
                <div id="left_content_big_cnt">
                    <div class="PageTitle">
                        <SharePointWebControls:FieldValue id="PageTitle2" FieldName="Title" runat="server"/>
                    </div>
                    <PublishingWebControls:RichHtmlField FieldName="PublishingPageContent" runat="server"></PublishingWebControls:RichHtmlField>
                    <WebPartPages:SPProxyWebPartManager runat="server" id="spproxywebpartmanager"></WebPartPages:SPProxyWebPartManager>
                        <WebPartPages:WebPartZone id="WPZone_Main" runat="server" title="Main"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
                </div>
            </div>
        </div>
        <div id="bottom_shadow" class="global_settings_containers">
        </div>
    </div>
</asp:Content>

Now all I need to do is add something to the repeater so it's only shown from the third level. Using a different page layout could be an option, but just as creating a webpart, not really preferred.

Any ideas?

share|improve this question

1 Answer 1

Answer edited into question by OP:

I fixed my problem with a bit of javascript. Not a very good solution, but it solves the problem for now. As Sharepoint doesn't work properly itself when javascript is disabled, it's not really an issue. The code used is:

    <script type="text/javascript">
        var segments = 0;
        var path = window.location.pathname;
        segments = path.split('/').length;
        //Hide the menu if we aren't 3 levels deep in the site.
        if( segments < 5 )
        {
            jQuery(".left_content_big_menu").hide();
        }
    </script>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.