Print Page | Close Window

Ordering Sub Forums Alphabetically

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=31510
Printed Date: 29 March 2026 at 8:11am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Ordering Sub Forums Alphabetically
Posted By: IanSmithISA
Subject: Ordering Sub Forums Alphabetically
Date Posted: 16 October 2017 at 11:36am
Good morning

I have a forum setup something like

Category

                Forum 1

                Forum 2

                                Sub Forum 1

                                Sub Forum 2

                                ……………

                                Sub Forum 20

I want to add Sub Forums frequently but I want them to show in alphabetic order.

Unless I am missing something I can’t drag and drop the sub forum in the page admin_view_forums.asp.

If I were to add a new sub forum that is to go before Sub Forum 2 for example I wanted to avoid having to update the order combo box for Sub Forum 3 -20 or possibly higher?

I did knock up the following query and it seems to work, but an official button would be nicer. J

DECLARE @ParentForumID INT

DECLARE @ParentForumOrder INT


-- Find the Forum ID for the forum that I want to order the sub forums for
SELECT @ParentForumID = Forum_ID,
       @ParentForumOrder = Forum_order
  FROM dbo.tblForum
 WHERE Forum_Name = Forum 2';
 
-- Make the forum order 1,2,3 etc based on the alphabetical order plus the forum_order of the parent
WITH NewValues AS
(
 SELECT Forum_ID, ROW_NUMBER() OVER (ORDER BY Forum_Name ASC) + @ParentForumOrder AS NewForumOrder
  FROM dbo.tblForum
 WHERE Sub_id = @ParentForumID
 )
UPDATE dbo.tblForum
   SET Forum_Order = NewValues.NewForumOrder
  FROM NewValues
  JOIN dbo.tblForum
ON NewValues.Forum_ID = dbo.tblForum.Forum_ID;
 

I realise that if I had a Forum 3 the above would make the last Sub Forum Forum_Order the same as the Forum Order for Forum 3, but I don’t have a forum 3 so am willing to accept it.

 Does anyone know of a reason why I shouldn’t do this?

Kind regards

Ian Smith

 



-------------
Why does anyone need more than an 80x25 character only VDU?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net