Usman ur Rehman Ahmed's blog

Toggle Partial Rendering for Module Controls in DNN

In DNN version 6.0 by default the module controls supports partial rendering/AJAX. Depending upon your needs (force download file for example) you can toggle this functionality as following,

Step 1

Go to Host > Extensions > Edit your module by clicking on the little pencil icon.

Step 2

Edit the desired module control for which you want to enable/disable "partial rendering" 

Module_controls
Step 3

Check/Uncheck "Supports partial rendering?" and press Update.

Supports_partial_rendering

How to add new reports in DNN Site Log?

This is a beginner level post and the purpose is to introduce you how SiteLog is organized and add a new report in Site Log.

First, we'll look at how Site Log works and then introduce a new report. At the core of Site Log there are two tables,

Lists (Table)

Lists table is used throughout DNN for a number of purposes. This table contains types of reports available in SiteLog type drop down. With a default DNN installation 12 reports are avaialble filtered by the field ListName as following,

Site_log_reports_drop_down

SELECT *

    FROM {databaseOwner}{objectQualifier}Lists where ListName = 'Site Log Reports'

The resultant shows that each record is assigned a unique value (identified by Value field) from 1 - 12.

Site_log_reports
SiteLog (Table) 

Thi s table contains data for site log which is used by the stored procedure to render.

GetSiteLog (Stored Procedure/s) 

GetSiteLog referres to a series of stored procedures each affixed by a number denoting which report it belongs to. For example SiteLog5 referrs to the Lists table record identified by Value field equal to 5 which is 'Page Views By Hour'.

How to add a new report in SiteLog

Step 1: To add a new report type, simply add a new record in Lists table providing it a new unique value. Please make sure that value is unqiue. Based over this unique value, the respective report stored procedure is called as we shall see.

Here I'll add a new report as existing report 'Page Views By Day' but that will list views by annonymous users only,

/* insert into the list of reports */
INSERT INTO {databaseOwner}[{objectQualifier}Lists]
           ([ListName]
           ,[Value]
           ,[Text]
           ,[ParentID]
           ,[Level]
           ,[SortOrder]
           ,[DefinitionID]
           ,[Description]
           ,[PortalId]
           ,SystemList)
     VALUES
           ('Site Log Reports'
           ,13
           ,'Anonymous Page Views By Day'
           ,0
           ,0
           ,0
           ,-1
           ,NULL
           ,-1
           ,1)
GO

So now our site log drop down will have a new report listed. However clicking on this report will report an error that GetSiteLog13 doesn't exiss so we need to create one.

Step 2: Create the stored procedure that outputs tabular data required to be rendered. Since we are only tweaking the 'Page Views By Day' data, we can simply use the existing stored proecredure GetSiteLog1 and change it a bit.

Here's how our new SP look like after changing,

/*This SP will return page views by day for annonymous users only.*/

CREATE procedure {databaseOwner}[{objectQualifier}GetSiteLog13]

@PortalID int,
@PortalAlias nvarchar(50),
@StartDate datetime,
@EndDate datetime

as

select datepart(weekday,DateTime) AS 'WeekDay',
 count(*) AS 'Views',
 count(distinct {objectQualifier}SiteLog.UserHostAddress) AS 'Visitors',
 count(distinct {objectQualifier}SiteLog.UserId) AS 'Users'
from dbo.SiteLog
where PortalId = @PortalID and UserId IS NULL
and {objectQualifier}SiteLog.DateTime between @StartDate and @EndDate
group by datepart(weekday,DateTime)
order by WeekDay

 

Swap current and next (may not be immediate) records

The stored procedures below can usually be used to swap two records fulfilling a given criteria.Note that the swapping will work even if some records between these two have been deleted. i.e. the monotonic sequence 0, 1, 2 ... is not strictly followed. (e.g. 0, 1, 3, 6, 7...)

The sample use demonstrated here is to swap the Display Priority of two recrods from the table ProjectsPerTab. Such a situation is often required in sorting item by item or giving precedence to one item over other as shown below,

Swap_records
ProjectsPerTab Table Schema

- pk (Primary key - int)

- TabId (Foreign Key from DNN Tabs table - int)

- ProjectFK (Projects table foreign key - int)

- DisplayPriority (int)

Move Down (Increase Display Priority/Swap with next record)

create procedure {databaseOwner}{objectQualifier}IncreaseProjectDisplayPriority
    @TabId int,
    @ProjectFK int
as
    begin
        -- Step 1: Retrieve display priority of this project and store that since that will be the last one to be updated

            declare @CurrentProjectDisplayPriority int
            select @CurrentProjectDisplayPriority = DisplayPriority from {objectQualifier}ProjectsPerTab where TabId = @TabId and ProjectFK = @ProjectFK

        -- Step 2: Exchange display priority with next one

            declare @pk int
            declare @DisplayPriority int

            -- Select minimum primary key for this tab with display priority greater than that of current project
            select @pk = min(pk) from {objectQualifier}ProjectsPerTab where TabId = @TabId and DisplayPriority > @CurrentProjectDisplayPriority
            select @DisplayPriority = DisplayPriority from {objectQualifier}ProjectsPerTab where pk = @pk

            if @pk is not null
            begin
                -- Exchange display priorities
                update {objectQualifier}ProjectsPerTab set DisplayPriority = @CurrentProjectDisplayPriority where pk = @pk
                update {objectQualifier}ProjectsPerTab set DisplayPriority = @DisplayPriority where TabId = @TabId and ProjectFK = @ProjectFK
            end

    end

GO

Move Up (Decrease Display Priority/Swap with previous record)

create procedure {databaseOwner}{objectQualifier}DecreaseProjectDisplayPriority
    @TabId int,
    @ProjectFK int
as
    begin
        -- Step 1: Retrieve display priority of this project and store that since that will be the last one to be updated

            declare @CurrentProjectDisplayPriority int
            select @CurrentProjectDisplayPriority = DisplayPriority from {objectQualifier}ProjectsPerTab where TabId = @TabId and ProjectFK = @ProjectFK

        -- Step 2: Exchange display priority with previous one

            declare @pk int
            declare @DisplayPriority int

            -- Select maximum primary key for this tab with display priority less than that of current project
            select @pk = max(pk) from {objectQualifier}ProjectsPerTab where TabId = @TabId and DisplayPriority < @CurrentProjectDisplayPriority
            select @DisplayPriority = DisplayPriority from {objectQualifier}ProjectsPerTab where pk = @pk

            if @pk is not null
            begin

                -- Exchange display priorities
                update {objectQualifier}ProjectsPerTab set DisplayPriority = @CurrentProjectDisplayPriority where pk = @pk
                update {objectQualifier}ProjectsPerTab set DisplayPriority = @DisplayPriority where TabId = @TabId and ProjectFK = @ProjectFK
            end

    end

GO

15
To Posterous, Love Metalab