Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

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 ForumsRepositoryRepositoryHow to display a single "random" itemHow to display a single "random" item
Previous
 
Next
New Post
2/21/2007 11:35 AM
 

Hi,

I would like to use the Repository to display Testimonials. There is a Testimonials module on snowcovered but it doesn't allow you to breakdown testimonials across different products, or to display testimonials from a central location to different pages.

Loading the testimonials is fine, but then I'd like to display a single testimonial as a "highlight", preferably random. 

Is there some way I can achieve this with what's already there? I thought of creating a page template set to display one item (actually the paging would then be quite neat), but didn't know how to get a way to roughly randomize it. The dashboards didn't look like they'd help because I could get to the title but not the description.

If one can't configure it to do something along these lines, can we add it as a feature request please?

Rozanne

 
New Post
6/29/2007 10:38 AM
 

Hi, just so you know - I wrote a standalone module that pulls a random repository item from a selected category and displays it, so you can still add this as a feature for other users if it's something they'd want, but I'm sorted now :-)  Thanks!

 
New Post
7/7/2007 2:44 AM
 

Could you send us a link to download this module ???

DV

 
New Post
9/13/2007 12:33 PM
 

The module wasn't written in a very generic way ... when we do modules just for ourselves, we tend to take shortcuts with the data adaptors, etc. But here is the code for the SP that will select a random file and display info for it, you could use it as the basis for your display module.

Note that my moduleId is hardcoded - you may want to make that a parameter also so the display is more generic.

CREATE PROCEDURE dbo.Repository_ShowRandomRecord

@category nvarchar(25)

AS
  -- GET A RANDOM TESTIMONIAL  

  declare @quick_tip_id int
  declare @rand_num int
  declare @num_recs int

  -- Get Random Number from number of records
  select @num_recs = count(obj.itemid) FROM grmRepositoryObjects obj INNER JOIN grmRepositoryCategories cat
  ON ';' + obj.CategoryID + ';' LIKE '%;' + CAST(cat.ItemID AS nvarchar(5)) + ';%'
  WHERE obj.ModuleID = 1837
  AND cat.Category = @category
  -- Select a random number between 1 and the number
  -- of records in our table
  
  -- Rounding error corrected by Finn Gundersen; old version commented below
  -- set @rand_num = Round(((@num_recs - 1) * Rand() + 1), 0)
          set @rand_num = Round(@num_recs * Rand() + 1, 0, 1)
       
  -- Create a local, static, read-only, scrollable cursor
  -- Needs scrollable to use fetch absolute, otherwise we
  -- would use forward-only
  declare #mycursor cursor scroll static read_only for
      --select itemid from grmrepositoryobjects where moduleid = 1837
  select obj.itemid FROM grmRepositoryObjects obj  INNER JOIN grmRepositoryCategories cat
  ON ';' + obj.CategoryID + ';' LIKE '%;' + CAST(cat.ItemID AS nvarchar(5)) + ';%'
   WHERE obj.ModuleID  = 1837
  AND cat.Category = @category

  open #mycursor
  fetch absolute @rand_num from #mycursor into @quick_tip_id
  close #mycursor
  deallocate #mycursor

  --select @quick_tip_id

  -- Select the columns from the table joined for the key
  -- selected from the cursor
  select obj.itemid as itemid, obj.moduleid as moduleid, isnull(name,'') as title, isnull(author,'') as author, isnull(description,'') as detail FROM
  grmrepositoryobjects obj --right join grmRepositoryCategories cat on cat.moduleid = obj.moduleid
  where obj.itemid  = @quick_tip_id
  --and cat.category = @category

GO

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsRepositoryRepositoryHow to display a single "random" itemHow to display a single "random" item


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