This is a migrated thread and some comments may be shown as answers.

NewsRotator to use pages

16 Answers 244 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Kristian
Top achievements
Rank 2
Kristian asked on 18 Nov 2010, 07:38 PM
So i would like to have the newsrotator to use pages, instead of news. I think i have the general idea here but I think i may have something incorrect in the fluent api. I end up getting

Must specify valid information for parsing in the string.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Must specify valid information for parsing in the string.

Source Error:


so in the page load for the rotator i set the rotators data source to use pages that are published
RadRotator1.DataSource =
                 App.WorkWith()
                     .Pages()
                     .Where(n => n.Page.Status == ContentLifecycleStatus.Live)
                     .Get()
                     .Take(this.NewsLimit)
                     .ToList()
                     .Join(App.WorkWith()
                                 .Images()
                                 .Get()
                                 .Where(i => i.Parent.Title == albumName.ToString() && i.Status == ContentLifecycleStatus.Live),
                                     item => item.Title.Value,
                                     image => image.Title.Value,
                                     (item, image) => new { NewsItem = item, NewsImage = image });

Then under data binding i use page instead of news item
Page newsItem =
                (Page)TypeDescriptor
                .GetProperties(e.Item.DataItem)["Page"]
                .GetValue(e.Item.DataItem);

Since pages has a description and not a summary I would like to use that
if (text != null) text.Text = newsItem.Description;

The target NewsPage uses typeof(NewsView), is there some sort of PageView?


as well as under the rotator when intialize controls i use Pages for the rotators datasource
this.RadRotator1.DataSource = App.WorkWith().Pages().Where(p => p.Page.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList().Join(
                    App.WorkWith().Images().Get().Where(i => i.Parent.Title == albumName && i.Status == ContentLifecycleStatus.Live),
                                                item => item.Title.Value,
                                                image => image.Title.Value,
                                                (item, image) => new { NewsItem = item, NewsImage = image });

16 Answers, 1 is accepted

Sort by
0
Kristian
Top achievements
Rank 2
answered on 19 Nov 2010, 08:28 PM
Ok i got this to work somewhat, I got it to pick up and go to pages link, although you still need to have the news item... still working on that portion.

But I wanted it to show the page description, similar to news summary, but it's not picking it up, but it will pick up things like url or title, and I have set a description on the page i want it to go to. Am i missing something?
if (text != null)
                {
                    var page = App.WorkWith().Pages().Where(p => p.Title == pageTitle).Get().FirstOrDefault();
                    text.Text = page.Description;
                }
0
Kristian
Top achievements
Rank 2
answered on 19 Nov 2010, 09:43 PM
Interesting, the description will only work when using a page manager
PageManager pageManager = PageManager.GetManager();
                    PageData page = pageManager.GetPageDataList().Where(pD => pD.Title == pageTitle).FirstOrDefault();
0
Hristo Borisov
Telerik team
answered on 22 Nov 2010, 09:53 AM
Hello Kristian,


Thank you for reporting this problem. We managed to reproduce the issue, and we will make sure that it is resolved in a timely manner. We are still polishing up the Fluent API, and my suggestions is to use the native API(Managers and no chaining of methods) in case you have issues with our new Fluent API.

Thank you once again, and excuse us for the inconvenience. Please let me know if there are any other issues, so that we can resolve them as soon as possible.

Sincerely yours,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hristo Borisov
Telerik team
answered on 22 Nov 2010, 02:55 PM
Hello Kristian,

After a second look over your code sample I noticed that in the first case you are calling the FluentAPI in order to retrieve the page which in itself gets the PageNode. The PageNode contains information for the UrlName and Navigation while the actual data of the page is stored in the PageNode.Page property. That is why, you have to access the page description in the following way:




Best wishes,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kristian
Top achievements
Rank 2
answered on 22 Nov 2010, 05:08 PM
Ah OK, thanks

One other question, is Tools a reserved word?
link.NavigateUrl = page.GetFullUrl().ToString();

I used this to navigate a page I called Tools, and I get directed to Sitefinity/Administration

I rename the content I need for my rotator to Tools1, and it works fine, whats up with that?
0
Hristo Borisov
Telerik team
answered on 22 Nov 2010, 05:43 PM
Hello Kristian,

After having a second look over the code I noticed that the Fluent API returns the PageNode that contains information for the Url and Navigation while the actual data of the page is stored in the PageNode.Page property. That is why you shouldn't have any issues accessing the page description in the following way:

var page = App.WorkWith().Pages().Where(p => p.Title == pageTitle).Get().FirstOrDefault();
text.Text = page.Page.Description;

We understand that it is a little bit confusing, and we will make sure to resolve those problems in the near term.

Best wishes,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kristian
Top achievements
Rank 2
answered on 22 Nov 2010, 08:02 PM
when I attempt using that i get this:

Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Sitefinity.Security.SecurityDemandFailException: Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

Source Error:

Line 606:
Line 607: var pages = App.WorkWith().Pages().Where(p => p.Title == pageTitle).Get().FirstOrDefault();
Line 608:
Line 609:



Using the pagemanager works fine for me
PageManager pageManager = PageManager.GetManager();
                    PageData page = pageManager.GetPageDataList().Where(pD => pD.Title == pageTitle).FirstOrDefault();
text.Text = page.Description;


on the other note can you explain / replicate an issue with a page name "Tools" in the previous post?
0
Kristian
Top achievements
Rank 2
answered on 22 Nov 2010, 09:51 PM
Besides that all I need now is to configure the radrotator datasource configured to use pages instead of news items under the initialize control method. That way I could create a page, and an image, and not have to have a news item be created for the rotator to work. However I'm getting 'object reference not set to an instance....' When I do this.. How are the pages setup to work this way?

this.RadRotator1.DataSource = App.WorkWith().Pages().Where(p => p.Page.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList().Join(
                    App.WorkWith().Images().Get().Where(i => i.Parent.Title == albumName && i.Status == ContentLifecycleStatus.Live),
                                                item => item.Title.Value,
                                                image => image.Title.Value,
                                               (item, image) => new { PageItem = item, NewsImage = image });
0
Hristo Borisov
Telerik team
answered on 24 Nov 2010, 10:13 AM
Hi Kristian,

You are getting the exception for the same reason as before. The Page facade returns all PageNodes and note that you use a PageNode to create both a Page and a PageGroup that is why you should perform a check whether the PageNode.Page similar to this:

this.RadRotator1.DataSource = App.WorkWith().Pages().Where(n => n.Page != null).Where(n => n.Page.Status == ContentLifecycleStatus.Live).Get().Take(this.NewsLimit).ToList().Join(
                                App.WorkWith().Images().Get().Where(i => i.Parent.Title == "Thumbnails" && i.Status == ContentLifecycleStatus.Live),
                                item => item.Title.Value,
                                image => image.Title.Value,
                                (item, image) => new { PageNode = item, NewsImage = image });

Let me know if you still have any issues creating your example.

Regards,
Hristo Borisov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kristian
Top achievements
Rank 2
answered on 29 Nov 2010, 03:08 PM
Thanks Hristo that helps, I know longer receive the exception

The rotator now shows up, but no images or text is displayed. Does it matter what location the pages are located in at the backend, I assume it would just pick up the first page that correctly equaled the name with the album image name?

if (sourceName == "Pages")
        {
 
                PageNode pageItem =
                    (PageNode)TypeDescriptor
                    .GetProperties(e.Item.DataItem)["PageNode"].GetValue(e.Item.DataItem);
             
                Telerik.Sitefinity.Libraries.Model.Image newsImage =
                    (Telerik.Sitefinity.Libraries.Model.Image)
                    TypeDescriptor.GetProperties(e.Item.DataItem)["NewsImage"].GetValue(e.Item.DataItem);
 if (image != null)
                {
                    image.ImageUrl = newsImage.MediaUrl;
                }
 
                if (imageBackgroundPanel != null)
                {
                    imageBackgroundPanel.BackImageUrl = newsImage.MediaUrl;
                }
 
                if (title != null)
                {                    title.Text = pageItem.Page.Title;
                   
                }
 
                if (text != null)
                {
                    PageManager pageManager = PageManager.GetManager();
                    PageData page = pageManager.GetPageDataList().Where(pD => pD.Title == pageItem.Page.Title).FirstOrDefault();
                     
 
                    if (page.Description.Length != 0)
                    {
                        text.Text = page.Description;
                    }
                    else
                    {
                        text.Text = "No Description";
                    }
                }
 
                if (link != null && this.TargetNewsPage != null)
                {
                    link.NavigateUrl = DataResolver.Resolve(pageItem.Page, "URL", null, this.TargetNewsPage.Id.ToString());
}
0
Ivan Dimitrov
Telerik team
answered on 29 Nov 2010, 03:58 PM
Hi Kristian,

1. Check whether image.ImageUrl is set and it has a value.

2. Make sure that you call this.RadRotator1.DataBind();, DataSource of the template is set.


Regards,
Ivan Dimitrov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kristian
Top achievements
Rank 2
answered on 29 Nov 2010, 08:37 PM
I went about it a bit differently and got the code working correctly. Hristo the page != null was just suppressing my exception so the datasource never got binded to the correct pages. by using a page manager i was able to get my list of pages and join them to my albums.

Thanks for the help guys, you have been great resource working through this!

PageManager pageManager = PageManager.GetManager();
 
                this.RadRotator1.DataSource = pageManager.GetPageDataList()
                    .Where(n => n.Status == ContentLifecycleStatus.Live).ToList().Join(
                        App.WorkWith().Images().Get()
                        .Where(i => i.Parent.Title == albumName && i.Status == ContentLifecycleStatus.Live),
                        item => item.Title.Value,
                        image => image.Title.Value,
                        (item, image) => new { PageData = item, NewsImage = image });

0
Kristian
Top achievements
Rank 2
answered on 16 May 2011, 05:33 PM
Hello, it's a been a while since i've seen the news rotator control brought up. I recently attempted upgrading this to use the virtual path provider but an encountered an error when using the control. As soon as you hit the 'play' button to auto scroll to the next time I run into a problem. using the next and previous buttons work fine. This happens when the switchMode function is called... any ideas?

function switchMode(sender, rotator, direction) {
    if (rotator.autoIntervalID) {
        //refreshButtonsState(sender, rotator)
        window.clearInterval(rotator.autoIntervalID);
        rotator.autoIntervalID = null;
    }
    else {
        //refreshButtonsState(clickedButton, rotator);
        rotator.autoIntervalID = window.setInterval(function () {
            rotator.showNext(direction);
        }, rotator.get_frameDuration());
    }
    refreshButtonsState(sender, rotator);
}
0
Niko
Telerik team
answered on 19 May 2011, 09:29 AM
Hello Kristian,

It is indeed strange that this error message is raised. Still I will need more info what may be causing this error - for example, on what line the error occurs? Is the rotator variable indeed a reference to a rotator object? Finally, how is the switchMode method called?

Kind regards,
Niko
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Kristian
Top achievements
Rank 2
answered on 19 May 2011, 01:41 PM
Ok well this only happens when you have the control set up in a virtual path provider. If you set it up the old way it works fine. I guess it doesn't matter too much, just curious on why this happens.

Example
http://screencast.com/t/eKoWKuL2eq1
0
Niko
Telerik team
answered on 20 May 2011, 09:38 AM
Hi Kristian,

This kind or errors are usually raised, when the object is null, not the property. In your case the reason for this behavior should be that the rotator variable is a null reference. Please, check this through debugging. The solution would be to check if there are other JavaScript error on page prior to this occurrence.


Regards,
Niko
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Rotator
Asked by
Kristian
Top achievements
Rank 2
Answers by
Kristian
Top achievements
Rank 2
Hristo Borisov
Telerik team
Ivan Dimitrov
Telerik team
Niko
Telerik team
Share this question
or