spLoadRecord_SiteContent

Parameters

Parameter Parameter Type Mode Description
@PKID int IN
@Status int IN
@VersionID int IN

Definition

Copy

    CREATE PROCEDURE [dbo].[spLoadRecord_SiteContent]
                (
                    @PKID int,
                    @Status int = 2,
                    @VersionID int = 0
                )
            AS
                /* @Status of 0 or 1 will return draft/pending state */

                -- result set #1
                select top 1 vsc.*
                from dbo.V_ALLCMSSITECONTENT vsc
                where vsc.ID = @PKID 
                and ((@VersionID > 0 and [SiteContentVersionID]=@VersionID)
                or (@VersionID = 0 
                and (([WorkflowID] is not null 
                        and ((@Status not in (0,1) and [Status] = @Status)
                        or (@Status in (0,1) and [Status] in (0,1,2))))
                    /* if no workflows are set for the content type, show pending (latest) version */
                    or ([WorkflowID] is null and [Status]=2))))
                order by [Status] asc

                -- result set #2
                    SELECT 
                        scf.ContentID, 
                        scf.SiteFoldersID, 
                        sf.FolderName 
                    FROM 
                        dbo.SiteContent sc
                        INNER JOIN dbo.SiteContentFolders scf ON scf.ContentID = sc.ID
                        INNER JOIN dbo.SiteFolders sf ON sf.FolderID = scf.SiteFoldersID 
                    WHERE 
                        sc.ID = @PKID 
                    ORDER BY 
                        sf.FolderName;