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

Forums / General Discussions / Version Number of news item?

Version Number of news item?

6 posts, 0 answered
  1. Josh
    Josh  avatar
    25 posts
    Registered:
    28 Apr 2009
    25 Oct 2010
    Link to this post
    HI,

    I have created a custom control similar to the News Item.  I would like to have a preview option where it displays a preview of a single news item before it is published similar to the Pages preview feature.   I currently have it going to the correct page and custom template, ListPageDetails.ascx, but I dont know how to show a specific version number of the item. 

    Kind Regards,

    Josh
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hello Josh ,

    You have to use VersionManager  to show a certain version of a given content item and mimic the preview mode.

    sample

    var cManager = new ContentManager("ProviderName");           
    VersionManager vm = new VersionManager();
    var item = vm.CreateItem(contentItem);
    var versionItemLink = cManager.Provider.ContentVersionViewUrl;
    // this returns the item version
    var v = item.Version;


    Kind regards,
    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
  3. Josh
    Josh  avatar
    25 posts
    Registered:
    28 Apr 2009
    25 Oct 2010
    Link to this post
    Hi Ivan,

    Thank you so much for the assistance.  I was also having a problem getting the content to save as a draft rather than as the live data

    StagedContent stagedC = (StagedContent)manager.GetStagedContent(myid.ID);
    stagedC.Content = this.Editor.Text;
    stagedC.Status = ContentStatus.Draft;
    manager.SavedStagedContent(stagedC, ContentStatus.Draft);

    In particular, line 4 seems to be saving the data but not as a draft.  In the history tab a new version is added but there is no rollback option to the old data similar to how the pages work.  is there a way to assign which version number i want to be the live one?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hi Josh ,

    The "Draft" status is reserved for the workflow and backend RadGrid control will display always "Published" status until you enable the workflow.

    Greetings,
    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
  5. Josh
    Josh  avatar
    25 posts
    Registered:
    28 Apr 2009
    26 Oct 2010
    Link to this post
    The "Draft" status may not be what I'm looking for then.

    In the Pages, when I preview, it appears to create a new version in the version history but leaves the current version as the live version. 

    What api call do i need to make with the versioning manager to save a version without making it live?
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Oct 2010
    Link to this post
    Hello Josh ,

    This is supported by the Generic Content based modules. As Ivan mentioned you need to enable workflow for those modules to be able to Save/Send for approval/Publish content items. For each Generic Content based module you have to allow worklow as bellow:
    <cmsEngine defaultProvider="Generic_Content">
        ...
            <providers>
            <clear />
            <add name="Generic_Content" urlRewriteFormat="[Publication_Date]/[Name].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="true" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data" />

    Then you will be able to use the API calls which Ivan has mentioned. To send an item through workflow you can use the bellow two metthods:

    private EventActivity FindActivity(string name, IList<Activity> activities)
    {
        foreach (Activity act in activities)
        {
            if ((act is EventActivity) && (((EventActivity)act).CommandName == name))
                return (EventActivity)act;
            EventActivity ea = FindActivity(name, act.Activities);
            if (ea != null)
                return ea;
        }
        return null;
    }
    private void ExecuteActivity(Guid id, string activityName)
    {
        WorkflowInstance instance = WorkflowRuntime.Instance.GetWorkflow(id);
        if (instance != null)
        {
            ContentWorkflow workflow = (ContentWorkflow)instance.Activity;
            EventActivity activity = FindActivity(activityName, workflow.Activities);
            if (activity != null)
            {
                activity.Execute(WorkflowRuntime.Instance);
            }
        }
    }

    You should call the ExecuteActivity method passing the WorkflowInstanceId of a staged content item:
    ExecuteActivity(staged.WorkflowInstanceId, "SendForApproval");


    Regards,
    Radoslav Georgiev
    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
Register for webinar
6 posts, 0 answered