Hi,
If I wanted to get the "most read" items under a itemtype, how could that be accomplished?
regards
jan
Hi,
If I wanted to get the "most read" items under a itemtype, how could that be accomplished?
regards
jan
Hi Jan
Use datalists and something in the line of this:
SELECT TOP (100) PERCENT COUNT(dbo.Statv2Page.Statv2PageID) AS antal, dbo.Page.PageID, dbo.Page.PageMenuText, dbo.ItemType_News.Heading FROM dbo.ItemType_News INNER JOIN dbo.Page ON dbo.ItemType_News.Id = dbo.Page.PageItemId INNER JOIN dbo.Statv2Page ON dbo.Page.PageID = dbo.Statv2Page.Statv2PagePageID WHERE (dbo.Page.PageItemType = N'News') GROUP BY dbo.Statv2Page.Statv2PagePageID, dbo.Page.PageID, dbo.Page.PageMenuText, dbo.ItemType_News.Heading ORDER BY antal DESC
This is for one of my item types - change it to the one you want to display.
Hi Nicolai,
Perfect. Works like a charm.
A follow up question:
If I wanted to type this in razor and use database directly there. WOuld that be recommended, or would you still suggest datalist?
And If I wanted to use the DB directly in a razor template - could you provide an example?
You could do it in Razor
string sql = "select something"; using IDatareader = Dynamicweb.Database.CreateDatareader(sql){ }
Something like that.
The thread Razor templates - connect to database [http://developer.dynamicweb-cms.com/forum/templates/razor-templates-connect-to-database.aspx] contains some examples on getting content from the Dynamicweb database using Razor.
Best regards,
Mikkel
You must be logged in to post in the forum