Hiding content widgets when viewing single news items
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.
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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");
Thanks.