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

Forums / Developing with Sitefinity / Back to category items list from preview

Back to category items list from preview

3 posts, 1 answered
  1. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    11 Jun 2010
    Link to this post
    I am trying to implement a back to category link in a ContentItemPreview view. How do I get the category of the content being previewed i.e. what is the implementation of the GetCurrentCategory method below...

    var hyperlink = this.Container.FindControl("BackToCategoryLink") as HyperLink;
    hyperlink.NavigateUrl = CreateHostViewCommand<ResourcesItemListView>(GetCurrentCategory());


    Thanks,

    Chris.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Jun 2010
    Link to this post
    Hi Chris,

    You can get the content item ID from the Pram QueyString and then call GetMetadata("Category") of the IContent object which will return the name of the category. In contentItem preview there is a method ShowMetaData that you could access and get the contentItem and its metadata (Category) directly.

    Another option is adding the category name as a QueryString parameter to the url and get the categoryfrom there.

    To navigate from ContentItemPreview to CategoriesView you have to use CreateRootViewCommand

    b.NavigateUrl = CreateRootViewCommand(typeof(GenericControlPanel), typeof(CategoriesView<GenericControlPanel>));

    You can gather more information at Sitefinity 3.6 new backend architecture - How to navigate among views: What are commands?

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    11 Jun 2010
    Link to this post
    Thanks. I didn't want to go back to the category list but the list of content in the same category, but I worked this out from your instructions...

    IContent content = base.Manager.GetContent(base.DataItemId);
    var categoryParamValue = String.Format("Category IN (\"{0}\")",  content.GetMetaData("Category"));
    var hyperlink = this.Container.FindControl("BackToCategoryLink") as HyperLink;
    hyperlink.NavigateUrl = CreateRootViewCommand(categoryParamValue, typeof(ResourcesControlPanel), typeof(ResourcesView));

Register for webinar
3 posts, 1 answered