1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Hiding content widgets when viewing single news items

Hiding content widgets when viewing single news items

3 posts, 0 answered
  1. Matt
    Matt avatar
    24 posts
    Registered:
    17 Sep 2009
    12 May 2011
    Link to this post
    I have about 10 news list pages where the client would like a short paragraph and title at the top of the page and then the news list below. When you click on a news item it generates the single news item below paragraphs placed above the news list.

    Anyone have a good suggestion on how to hide the other content widgets when viewing the single news item on a page?

    I have tested using a different page to display the single news item but then the search index is picking up both pages and creating 10 single item pages that link back to the original list pages seems like a lot of work for every category of news. 
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    18 May 2011
    Link to this post
    Hi Matt,

    That's a tough one, we do not offer this functionality out of the box. But you ca easily achieve it by wrapping the content you want to display/hide inside a <div> tag and set this div's style="display:none" when the URLof the page contains a specific pattern. Please take a look at the sample master page below which has two ContetnplaceHolders one of which is wrapped in a div that I'm manipulating from the codebehind, and when I open my "testnewsitem" in details page the content placed in the first placeholder is hidden from the page.
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="SitefinityWebApp.App_Master.Site1" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="HiddenContent" runat="server"  >
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">       
            </asp:ContentPlaceHolder>
        </div>
     
        <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
        </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Web;
    using Telerik.Sitefinity.Modules.Pages;
     
    namespace SitefinityWebApp.App_Master
    {
        public partial class Site1 : System.Web.UI.MasterPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                
                var Url = HttpContext.Current.Request.Url;
                if (Url.ToString().Contains("testnewsitem"))
                {
                    HiddenContent.Attributes.Add("style", "display:none");
                }
                 
            }
        }
    }
    I hope you find this information useful. If you have any additional questions, please let us know.


    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Matt
    Matt avatar
    24 posts
    Registered:
    17 Sep 2009
    20 May 2011
    Link to this post
    Thanks.
3 posts, 0 answered