Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Ordering Sub Forums Alphabetically
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ordering Sub Forums Alphabetically

 Post Reply Post Reply
Author
IanSmithISA View Drop Down
Groupie
Groupie


Joined: 21 October 2010
Location: Worcester
Status: Offline
Points: 127
Post Options Post Options   Thanks (0) Thanks(0)   Quote IanSmithISA Quote  Post ReplyReply Direct Link To This Post Topic: Ordering Sub Forums Alphabetically
    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?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.