-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEED TO VERSION - Add DisplayOrder column to DnnForge_NewsArticles_Ar…
…ticleTag table and allow for explicitly defining display order via ucSubmitNews UI
- Loading branch information
Eric Wagner
committed
Mar 8, 2021
1 parent
0f641a8
commit de8c205
Showing
9 changed files
with
318 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Providers/DataProvider/SqlDataProvider/VersionMe.SqlDataProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
-- Add SortOrder column to DnnForge_NewsArticles_ArticleTag | ||
IF (SELECT TOP 1 c.column_id | ||
FROM sys.tables t | ||
JOIN sys.all_columns c ON t.object_id = c.object_id | ||
WHERE t.name = 'DnnForge_NewsArticles_ArticleTag' AND c.name = 'DisplayOrder') IS NULL | ||
BEGIN | ||
|
||
ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag | ||
ADD DisplayOrder INT | ||
|
||
-- Backfill existing article tags | ||
UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag | ||
SET DisplayOrder = 0 | ||
|
||
END | ||
GO | ||
|
||
-- Add DisplayOrder param to DnnForge_NewsArticles_ArticleTagAdd store procedure | ||
ALTER PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagAdd | ||
@ArticleID int, | ||
@TagID int, | ||
@DisplayOrder int | ||
AS | ||
IF( (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag WHERE ArticleID = @ArticleID and TagID = @TagID) = 0 ) | ||
BEGIN | ||
INSERT INTO | ||
{databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag(ArticleID, TagID, DisplayOrder) | ||
VALUES(@ArticleID, @TagID, @DisplayOrder) | ||
|
||
UPDATE | ||
{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag | ||
SET | ||
Usages = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag pt where pt.TagID = @TagID) | ||
WHERE | ||
TagID = @TagID | ||
END | ||
GO | ||
|
||
-- Alter Ventrian_NewsArticles_SplitTags function to order article tags by DisplayOrder field | ||
ALTER FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags | ||
(@ArticleID int) | ||
RETURNS nvarchar(2000) | ||
AS | ||
BEGIN | ||
|
||
DECLARE @p_str nvarchar(2000) | ||
SET @p_str = '' | ||
|
||
SELECT @p_str = @p_str + ',' + CAST(t.[Name] AS NVARCHAR(50)) | ||
FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag at | ||
WHERE t.TagID = at.TagID and at.ArticleID = @ArticleID | ||
ORDER BY at.DisplayOrder | ||
|
||
IF( LEN(@p_str) > 0 ) | ||
BEGIN | ||
SELECT @p_str = SUBSTRING(@p_str, 2, (LEN(@p_str)-1)) | ||
END | ||
|
||
RETURN LTRIM(@p_str) | ||
|
||
END | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.