Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsDocumentsDocumentsSort Order not working... apparently.Sort Order not working... apparently.
Previous
 
Next
New Post
7/29/2008 5:57 AM
 

Well... this works only for the title, and not for the columns set in the settings, which are completely ignored.

If you're courageous enough, run this script (from Host :: SQL - don't forget to check "Run as script", and I strongly recommend that you make a backup of the {objectQualifier}GetDocuments procedure before you do that. I tried it using SQL Server 2005 Express, DNN 04.08.04 and Documents 04.00.00, and it worked for me, but if you do that, you'll do it at your own risk!!!):

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE {databaseOwner}{objectQualifier}GetDocuments

@ModuleId int,
@PortalId int
AS
DECLARE @SortOrder nvarchar(2000)
DECLARE @sql nvarchar(max)


SET @SortOrder = (SELECT SortOrder FROM {databaseOwner}{objectQualifier}DocumentsSettings WHERE ModuleID = @ModuleId)

SET @SortOrder = REPLACE(@SortOrder, '-SortIndex', '{objectQualifier}Files.{objectQualifier}Documents.SortOrderIndex DESC')
SET @SortOrder = REPLACE(@SortOrder, 'SortIndex', '{objectQualifier}Files.{objectQualifier}Documents.SortOrderIndex')
SET @SortOrder = REPLACE(@SortOrder, '-Title', '{objectQualifier}Files.{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Title', '{objectQualifier}Files.{objectQualifier}Documents.Title')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Title')
SET @SortOrder = REPLACE(@SortOrder, '-Owner', 'OwnedByUser.LastName + '' '' + OwnedByUser.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Owner', 'OwnedByUser.LastName + '' '' + OwnedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '-Category', '{objectQualifier}Files.{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Category', '{objectQualifier}Files.{objectQualifier}Documents.Category')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Category')
SET @SortOrder = REPLACE(@SortOrder, '-ModifiedDate', '{objectQualifier}Files.{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'ModifiedDate', '{objectQualifier}Files.{objectQualifier}Documents.ModifiedDate')
SET @SortOrder = REPLACE(@SortOrder, '###', 'ModifiedDate')
SET @SortOrder = REPLACE(@SortOrder, '-Size', '{objectQualifier}Files.{objectQualifier}Files.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Size', '{objectQualifier}Files.{objectQualifier}Files.Size')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Size')
SET @SortOrder = REPLACE(@SortOrder, '-CreatedBy', '###User.LastName + '' '' + ###User.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'CreatedBy', 'CreatedByUser.LastName + '' '' + CreatedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '###', 'CreatedBy')
SET @SortOrder = REPLACE(@SortOrder, '-CreatedDate', '{objectQualifier}Files.{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'CreatedDate', '{objectQualifier}Files.{objectQualifier}Documents.CreatedDate')
SET @SortOrder = REPLACE(@SortOrder, '###', 'CreatedDate')
SET @SortOrder = REPLACE(@SortOrder, '-ModifiedBy', '###User.LastName + '' '' + ###User.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'ModifiedBy', 'ModifiedByUser.LastName + '' '' + ModifiedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '###', 'ModifiedBy')
SET @SortOrder = REPLACE(@SortOrder, '-Description', '{objectQualifier}Files.{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Description', '{objectQualifier}Files.{objectQualifier}Documents.Description')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Description')
SET @SortOrder = REPLACE(@SortOrder, '-Clicks', '{objectQualifier}Files.{objectQualifier}UrlTracking.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Clicks', '{objectQualifier}Files.{objectQualifier}UrlTracking.TrackClicks')
SET @SortOrder = REPLACE(@SortOrder, '###', 'TrackClicks')

SET @sql = '
SELECT     {objectQualifier}Documents.ItemID, {objectQualifier}Documents.ModuleID, {objectQualifier}Documents.Title, {objectQualifier}Documents.URL, 
                      CreatedByUser.FirstName + '' '' + CreatedByUser.LastName AS ''CreatedByUser'', 
                      OwnedByUser.FirstName + '' '' + OwnedByUser.LastName AS ''OwnedByUser'', 
                      ModifiedByUser.FirstName + '' '' + ModifiedByUser.LastName AS ''ModifiedByUser'', {objectQualifier}Documents.Category, {objectQualifier}Files.Size, {objectQualifier}UrlTracking.TrackClicks, 
                      {objectQualifier}UrlTracking.Clicks, {objectQualifier}UrlTracking.NewWindow, {objectQualifier}Documents.OwnedByUserID, {objectQualifier}Documents.ModifiedByUserID, {objectQualifier}Documents.ModifiedDate, 
                      {objectQualifier}Documents.CreatedByUserID, {objectQualifier}Documents.CreatedDate, {objectQualifier}Documents.SortOrderIndex, {objectQualifier}Documents.Description
FROM         {objectQualifier}Documents LEFT OUTER JOIN
                      {objectQualifier}Users AS CreatedByUser ON {objectQualifier}Documents.CreatedByUserID = CreatedByUser.UserID LEFT OUTER JOIN
                      {objectQualifier}Users AS OwnedByUser ON {objectQualifier}Documents.OwnedByUserID = OwnedByUser.UserID LEFT OUTER JOIN
                      {objectQualifier}Users AS ModifiedByUser ON {objectQualifier}Documents.ModifiedByUserID = ModifiedByUser.UserID LEFT OUTER JOIN
                      {objectQualifier}Files ON {objectQualifier}Documents.URL = ''fileid='' + CONVERT(varchar, {objectQualifier}Files.FileId) LEFT OUTER JOIN
                      {objectQualifier}UrlTracking ON {objectQualifier}Documents.URL = {objectQualifier}UrlTracking.Url AND {objectQualifier}UrlTracking.ModuleId = ' + CAST(@ModuleId AS nvarchar(10)) + '
WHERE     ({objectQualifier}Documents.ModuleID = ' + CAST(@ModuleId AS nvarchar(10)) + ')'

IF NOT LEN(@SortOrder) = 0
   SET @sql = @sql + ' ORDER BY ' + @SortOrder

EXEC sp_executesql @sql

Good luck!

Michael


Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
7/30/2008 3:11 PM
 

Here is a fixed version of the above which had a bunch of stray "{objectQualifier}Files." where "{databaseOwner}" should have been:

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE {databaseOwner}{objectQualifier}GetDocuments

@ModuleId int,
@PortalId int
AS
DECLARE @SortOrder nvarchar(2000)
DECLARE @sql nvarchar(max)


SET @SortOrder = (SELECT SortOrder FROM {databaseOwner}{objectQualifier}DocumentsSettings WHERE ModuleID = @ModuleId)

SET @SortOrder = REPLACE(@SortOrder, '-SortIndex', '{databaseOwner}{objectQualifier}Documents.SortOrderIndex DESC')
SET @SortOrder = REPLACE(@SortOrder, 'SortIndex', '{databaseOwner}{objectQualifier}Documents.SortOrderIndex')
SET @SortOrder = REPLACE(@SortOrder, '-Title', '{databaseOwner}{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Title', '{databaseOwner}{objectQualifier}Documents.Title')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Title')
SET @SortOrder = REPLACE(@SortOrder, '-Owner', 'OwnedByUser.LastName + '' '' + OwnedByUser.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Owner', 'OwnedByUser.LastName + '' '' + OwnedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '-Category', '{databaseOwner}{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Category', '{databaseOwner}{objectQualifier}Documents.Category')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Category')
SET @SortOrder = REPLACE(@SortOrder, '-ModifiedDate', '{databaseOwner}{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'ModifiedDate', '{databaseOwner}{objectQualifier}Documents.ModifiedDate')
SET @SortOrder = REPLACE(@SortOrder, '###', 'ModifiedDate')
SET @SortOrder = REPLACE(@SortOrder, '-Size', '{databaseOwner}{objectQualifier}Files.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Size', '{databaseOwner}{objectQualifier}Files.Size')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Size')
SET @SortOrder = REPLACE(@SortOrder, '-CreatedBy', '###User.LastName + '' '' + ###User.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'CreatedBy', 'CreatedByUser.LastName + '' '' + CreatedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '###', 'CreatedBy')
SET @SortOrder = REPLACE(@SortOrder, '-CreatedDate', '{databaseOwner}{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'CreatedDate', '{databaseOwner}{objectQualifier}Documents.CreatedDate')
SET @SortOrder = REPLACE(@SortOrder, '###', 'CreatedDate')
SET @SortOrder = REPLACE(@SortOrder, '-ModifiedBy', '###User.LastName + '' '' + ###User.FirstName DESC')
SET @SortOrder = REPLACE(@SortOrder, 'ModifiedBy', 'ModifiedByUser.LastName + '' '' + ModifiedByUser.FirstName')
SET @SortOrder = REPLACE(@SortOrder, '###', 'ModifiedBy')
SET @SortOrder = REPLACE(@SortOrder, '-Description', '{databaseOwner}{objectQualifier}Documents.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Description', '{databaseOwner}{objectQualifier}Documents.Description')
SET @SortOrder = REPLACE(@SortOrder, '###', 'Description')
SET @SortOrder = REPLACE(@SortOrder, '-Clicks', '{databaseOwner}{objectQualifier}UrlTracking.### DESC')
SET @SortOrder = REPLACE(@SortOrder, 'Clicks', '{databaseOwner}{objectQualifier}UrlTracking.TrackClicks')
SET @SortOrder = REPLACE(@SortOrder, '###', 'TrackClicks')

SET @sql = '
SELECT {objectQualifier}Documents.ItemID, {objectQualifier}Documents.ModuleID, {objectQualifier}Documents.Title, {objectQualifier}Documents.URL,
CreatedByUser.FirstName + '' '' + CreatedByUser.LastName AS ''CreatedByUser'',
OwnedByUser.FirstName + '' '' + OwnedByUser.LastName AS ''OwnedByUser'',
ModifiedByUser.FirstName + '' '' + ModifiedByUser.LastName AS ''ModifiedByUser'', {objectQualifier}Documents.Category, {objectQualifier}Files.Size, {objectQualifier}UrlTracking.TrackClicks,
{objectQualifier}UrlTracking.Clicks, {objectQualifier}UrlTracking.NewWindow, {objectQualifier}Documents.OwnedByUserID, {objectQualifier}Documents.ModifiedByUserID, {objectQualifier}Documents.ModifiedDate,
{objectQualifier}Documents.CreatedByUserID, {objectQualifier}Documents.CreatedDate, {objectQualifier}Documents.SortOrderIndex, {objectQualifier}Documents.Description
FROM {objectQualifier}Documents LEFT OUTER JOIN
{objectQualifier}Users AS CreatedByUser ON {objectQualifier}Documents.CreatedByUserID = CreatedByUser.UserID LEFT OUTER JOIN
{objectQualifier}Users AS OwnedByUser ON {objectQualifier}Documents.OwnedByUserID = OwnedByUser.UserID LEFT OUTER JOIN
{objectQualifier}Users AS ModifiedByUser ON {objectQualifier}Documents.ModifiedByUserID = ModifiedByUser.UserID LEFT OUTER JOIN
{objectQualifier}Files ON {objectQualifier}Documents.URL = ''fileid='' + CONVERT(varchar, {objectQualifier}Files.FileId) LEFT OUTER JOIN
{objectQualifier}UrlTracking ON {objectQualifier}Documents.URL = {objectQualifier}UrlTracking.Url AND {objectQualifier}UrlTracking.ModuleId = ' + CAST(@ModuleId AS nvarchar(10)) + '
WHERE ({objectQualifier}Documents.ModuleID = ' + CAST(@ModuleId AS nvarchar(10)) + ')'

IF NOT LEN(@SortOrder) = 0
SET @sql = @sql + ' ORDER BY ' + @SortOrder

EXEC sp_executesql @sql

Same instructions as above; don't forget to check "Run as script". This worked for me on Documents 4.0.0, DNN 4.5.5, and SQL Server 2000 (after changing the nvarchar(max) to nvarchar(4000) - The script as provided should be fine for SQL Server 2005).

Thanks go to Michael, and enjoy!


Brad Montgomery
Engage Software
St. Louis, MO
314.966.4000

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsDocumentsDocumentsSort Order not working... apparently.Sort Order not working... apparently.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out