Products

Solutions

Resources

Partners

Community

About

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 ForumsLinksLinksHow to sort links?How to sort links?
Previous
 
Next
New Post
6/8/2010 4:32 PM
 
I have a large number of links with dates, and I need to reverse the order they are in. Is there an easy way to do this? Here is an example of the name format:

09.12.17
09.12.24
10.01.15
10.02.14

View order would be a lot of work. I'm hoping for a much less time intensive solution. 

Thanks!
 
New Post
6/8/2010 7:28 PM
 

This is doable, but you will need to execute some SQL after each update of the links. 

The first issue is the vieworder is a integer value so we must convert the date string to a numeric value - such as following ( assumes date is at the beginning of Link Title)

select Cast(SUBSTRING(Title, 1, 2) as int) * 10000
     + Cast(SUBSTRING(Title, 4, 2) as int) * 100
     + Cast(SUBSTRING(Title, 8, 2) as int)
     as ViewOrder from dbo.Links.

This will take a title of "09.12.17" and generate a vieworder of 91217.

Next issue is the need to reverse the display order.  The first link display will have the lowest value, so we need to invert the results of the select

select 1000000 - (Cast(SUBSTRING(Title, 1, 2) as int) * 10000
     + Cast(SUBSTRING(Title, 4, 2) as int) * 100
     + Cast(SUBSTRING(Title, 8, 2) as int) )
     as ViewOrder from dbo.Links.


Since the largest possible value could be 991212, I will use 1000000 as the upper value and subtract the generated value - this will invert the value of the vieworder.  For example. this will result in "09.12.17" becoming  908793, and 10.02.14 becoming 899796.  The second value is a lower value than the first and therefore will displayed before the first value.

So, to make this work we need to update the vieworder column in the links table for the specific moduleid associated with the Links.  How can we determine the ModuleID?  When you add a link to the module, the URL of the edit page will be something like 

    www.mysite.com/Home/tabid/54/ctl/Edit/mid/395/ItemID/42/Default.aspx

The mid/395 defines the moduleid (395) for this instance of the Links Module. 

So we have everything we need:

Update dbo.Links
   set vieworder = 1000000 - (Cast(SUBSTRING(Title, 1, 2) as int) * 10000
     + Cast(SUBSTRING(Title, 4, 2) as int) * 100
     + Cast(SUBSTRING(Title, 8, 2) as int) )
where moduleid = 395           <----- change this to appropriate moduleID

You will need to sign on as Host and use the SQL page to execute the update -- or if you have direct access to the database you can do it from some SQL utility such as MS SSMS.   You will need to do this every time you add a link to the module.

Also, I did not add an objectqualifier and used dbo as the database owner.  If needed change dbo.Link to {DatabaseOwner}. {ObjectQualifier}Links

Hope this helps
Paul.

 
New Post
6/10/2010 4:09 AM
 
Another option would be sorting by description descending and update vieworder with RowID, what do you think, Paul? this would generate smaller values and is able to handle non-numeric captions as well w/o generating an error. In any case, view orders may need to be updated after records are inserted/updated. to solve this, you may consider using UserDefinedTable aka Form and List instead of links module. The module allows you to specify the search column and sort order.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
6/15/2010 9:41 PM
 
Sebastian, 

Yes your suggestion would work ... I was going for a way that could handle the date information from anywhere in the title -- by adjusting the substrings accordingly.   Also some out of the box thinking to show what is possible given the limitations.

it was a fun exercise - over lunch.

Paul.
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsLinksLinksHow to sort links?How to sort links?


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