Prevent Detail Mode

Posted by Community Admin on 04-Aug-2018 04:31

Prevent Detail Mode

All Replies

Posted by Community Admin on 23-Jan-2013 00:00

If I have my widget set to load the "Detail" in a new page, I VERY MUCH don't want it to still toggle into detail mode...

 How can that be prevented?

Posted by Community Admin on 26-Jan-2013 00:00

This was an interesting one, and I've had this problem before myself in sites... I agree this should be out of the box.  Here was what I did, I'm sure it can be improved, but consider it v0.1:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Sitefinity.Modules.News.Web.UI;
using System.Web.UI;
using Telerik.Sitefinity.Web;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Fluent.Pages;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Sitefinity.News.Model;
 
namespace SitefinityWebApp
    public class TestNews : NewsView
        //If detail item is requested on the list page, should I redirect to detail Page?
        //If false, the control will just pass and probably get a 404
        public bool redirectToDetailPage get; set;
        private bool wrongPage = false;
        private bool redirected = false;
 
        protected override void OnLoad(EventArgs e)
            base.OnLoad(e);
 
            //Only allow DETAILVIEW on Detail Page
            this.ResolveDetailItem();
            var thisNode = SiteMapBase.GetActualCurrentNode();
 
            if (thisNode != null //E.g., Not on a page template
            && this.DetailItem != null //A single item is being displayed
            && this.MasterViewDefinition.DetailsPageId != Guid.Empty //NewsView set to show item on detail page
            && thisNode.Id != this.MasterViewDefinition.DetailsPageId) //And this page isn't the detail page
                //Set this for later
                wrongPage = true;
 
                //Redirect to detail page
                if (redirectToDetailPage)
                    //Only if the details page is published etc...
                    var detailPage = App.WorkWith().Pages().LocatedIn(PageLocation.Frontend).ThatArePublished()
                        .Where(p => p.Id == this.MasterViewDefinition.DetailsPageId).Get()
                        .SingleOrDefault();
 
                    //Didn't know a generic way to get DetailItem Url
                    var itemUrl = ((NewsItem)DetailItem).Urls.Single(u => u.IsDefault).Url;
 
                    if (detailPage != null)
                        //Do the redirect
                        var detailUrl = ResolveUrl(string.Format("0/1", detailPage.GetFullUrl(), itemUrl));
                        this.Context.Response.Redirect(detailUrl);
                        redirected = true;
                    
                
            
        
 
        protected override void OnPreRender(EventArgs e)
            base.OnPreRender(e);
 
            //If it's an error and wasn't redirected earlier, then goto a 404 page
            if (wrongPage && !redirected)
                RouteHelper.SetUrlParametersResolved(false);
            
        
    

Posted by Community Admin on 28-Jan-2013 00:00

Hello,

I suppse on the page where you redirect with the news widget you have placed news widget with a setting in advanced properties-> ContentViewDisplayMode -> Detail. This makes the widget display only news items in details mode and in the URL doesn`t match valid news item URL (/2013/01/01/test, PublicationDate,Url) it will not display news items unless the url matches the news item url pattern.
I think I miss the point of the question
"If I have my widget set to load the "Detail" in a new page, I VERY MUCH don't want it to still toggle into detail mode." When a news item is selected and it opens in the predefined page redirecting to the news item details what needs to be displayed?

Regards,
Stanislav Velikov
the Telerik team

Posted by Community Admin on 28-Jan-2013 00:00

"If I have my widget set to load the "Detail" in a new page, I VERY MUCH don't want it to still toggle into detail mode." When a news item is selected and it opens in the predefined page redirecting to the news item details what needs to be displayed?

We're talking dynamic content mostly not news, although I'm sure it happens in news too.

Okay so drop in the default widget, in single mode set it to open in a new page, pick the page

Now in live on the list view just change the url to be one if the detail items

/mycontent/item1 <- will work, shouldn't
/mycontent/detail/item1 <- page I set it to
(duplicate content)

Know what I mean?

This thread is closed