Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module

Blog 2
Location: BlogsAll BlogsDNN Development    
Posted by: mamlin 10/13/2008 1:57 AM

(2010 Update)  Will Strohl has given a different example of creating a "Most-Comented Blogs" listing using the now-updated DNN "REPORTS" module.  Will's example is much more elegant and powerful than the example I presented back in 2008 (shown below) thanks to the REPORTS module's support for XSLT.  Check out Will's solution here!

Another example of using the free AdvancedDataGrid module to instantly create new functionality on your site.  This time we'll create a clickable "Most Commented Blogs" list (just like the one used on this site) to use with the standard DNN Blog module...


Useful by Example
The best way to illustrate just how immenently useful "SQL" modules are is to show real-world examples.  In case you missed Part 1 and Part 2, "SQL" modules allow you to execute your own database query and present the results as a table in a webpage.  This, in effect, allows you to use SQL queries to effectively contruct your own DNN modules.

There are several "SQL" modules availalbe for DNN.  I prefer to use free offerings when possible so I really like the open-sourced "Advanced Datagrid" module and the closed-source-but-more-powerful "SQLView" module. 


Most-Commented Blogs

In this example we'll use the "Advanced DataGrid" module to create the same "Most Commented Blogs" box you see on this page.  The result will be a simple 1-column table with a clickable list of blog entry titles reflecting the five blogs with the most user comments.  

Our example is using the DNN core "BLOG" module -- if you're using a different modlue for blogging then this example will need to be modified to fit you blog module's database schema.  

Setting this up to show data from the DNN BLOG module is a simple two-step process:

(1) Add the "Advanced Datagrid" module to a page.
(2) In the module settings, copy-and-paste the SQL query into the settings.

Here's the SQL query: 
NOTE:  For formatting purposes, all HTML tags are shown with an extra space just 
after the "
<" symbol and just before the closing ">" symbol.  You will need to remove 
the extra spaces if you copy-and-paste code directly from this page

 
select Title from
(
select top 5 count(*) as [#],
  '< a href="'+(select ble.PermaLink 
   from blog_entries ble 
   where ble.entryid = blc.entryid)+'">'+
  (select ble.Title 
   from blog_entries ble 
   where ble.entryid = blc.entryid)+'< /a >'
   as [Title]
from blog_comments blc
where blc.approved = 1
group by blc.entryid
order by [#] desc
) as Result1

 
 
As you can see, the query contructs HTML links using the blog entries' "PermaLink" values as the links and the "Title" values as the displayed link text.  This works great since the Advanced Datagrid renders results as HTML rather than just plain text.  If you prefer to display only the "top 3" or as many as "top 10" posts instead of "top 5" simply change the value between "top" and "count" on line 2.

That's it!  Super simple but very effective.  It should be easy to see how you could use the same approach to creating all sorts of lists:  most-active users, most-visited pages, most recent login failures (a good admin tool), etc.

 

Permalink |  Trackback

Comments (5)   Add Comment
Re: Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module
Swaminathan.T    5/17/2009 11:20 PM
Hi, Can you provide me a working sample for displaying the latest blog posts in the Advanced datagrid module. Awaiting your reply asap. Thanks, Swaminathan.

Re: Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module
mamlin    5/17/2009 11:29 PM
Swaminathan- A list of "latest blogs" will depend upon your specific need. Do you have more than one blog category? Do you have child blogs? Do you have more than one blog author? There are many potential variations of a "most recent" list based on these variables. On the homepage of this site I've used Advanced Datagrid to show the most recent blog entries of any blog category and any author without constraint to or omission of any child blog(s). Is that the variation you're seeking?

Re: Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module
Swaminathan.T    5/21/2009 9:43 AM
yes i have more than 1 blog author. Right now i don't have any child blogs. I just want to display the latest blog posts that has been created in my website in advanced datagrid module . viz. title, summary etc in link format and on clicking those links, it should take to corresponding blog posts in my website.

Re: Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module
mamlin    5/21/2009 9:52 AM
Swaminathan- I have added a new post on how to add a clickable "latest blogs" list using the core REPORTS module. The example I provided meets your stated needs. If you want to stick with the Advanced Datagrid module, you will need to change the example SQL portalID token from the REPORTS token "@portalID" to the Advanced Datagrid token "[dnn:portalID]". The current version of REPORTS now does more than Advanced Datagrid so I will be using REPORTS for my examples from now on. I will also continue to give examples using the free SQLVIEW module whenever querystring support is required. The new post is here: http://www.eguanasolutions.com/DNN_Blog/EntryID/34.aspx

Re: Free DNN Module: Advanced DataGrid (Part 3) - Create a "Most Commented Blogs" module
Amresh    12/8/2011 12:59 AM
nice module


Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
You are here:  
 
>> Back to the top of the blog list...

 
        account   blog   click   cloud   code   create   data   events   example   feature   file   files   free   function   good   google   just   line   links   list   module   modules   need   note   number   option   page   pages   query   results   role   roles   script   search   select   settings   simple   site   skin   solution   step   tags   terms   time   user   users   value   version   want  
Minimize Google AJAX Search
 
Search ES:  
This is an example of a Google AJAX Search with asynchronous search execution for two searches.  See our blog series, 'Add Google AJAX Search to your DNN skin' for info and sample code.
 
     
Minimize Buy Stuff
 
Stuff by Eguana Solutions
(Be sorta cool!)
 
     
Minimize Most-Commented Blogs
 
 
     

Minimize Looking for more info?
 

There are tons of helpful
posts from Eguana Solutions 
on the DotNetNuke.com forums.
  
 
Click HERE to see our posts.

 
     
Minimize Modules for Sale
 

Looking for Eguana's modules? 
We're still working on them!
  

Until ours are ready to dazzle and
amaze, you'll have to make do with
the thousands of modules already
available on SnowCovered.

 
     
Minimize Favorite Modules
 

There are many great DNN modules.
A few we highly recommend are:
 
Dynamic Registration
Total control over the user signup process.  Create custom forms, execute your own SQL, use the integrated payment processing features to assign user roles, validate USERNAMEs via AJAX and much more.  Very cool.
 
URL Master
Change to friendly URLs that really ARE friendly.  Add keywords into your page URLs for better SEO.  Create 301 redirects for individual pages.  Force visitors (and search bots) to a single domain (i.e., make everyone use the "www" version of your site's URL or vice versa).  One of the single best upgrades for any DNN site.
 
Document Exchange 5 (DMX5)
Drag-and-drop from Windows Explorer directly into the DMX file manager!  File versioning, file and folder moderation, extend user permissions down to the file level (for user groups and even for individual users).  Infinite file and file info presentation options via custom display templates.  Store files locally or remotely via UNC (i.e., can securely store files somewhere besides your web server).  Much more.
 
XMOD by DNNDev
Rock-solid form module for data collection.  From simple feedback / email forms to complex, multi-part tabbed forms.  XMOD is different from other form modules because XMOD does not create a new database table for every new form definition -- an important feature if you plan to create dozens or hundreds of forms over the life of your DNN instance!  Excellent support from the developer and an active community around this module.
 
If you desire your form module to create a new DB table for each new form definition, a great alternative to XMOD is the Dynamic Forms module from DataSprings.  Dynamic Forms offers direct DB access beyond that found in XMOD as well as an easy drag-and-drop form builder option to help you get up and running very quickly.

 
     

Login