Skip to content

Instantly share code, notes, and snippets.

@ajtroxell
Created March 4, 2014 16:26
Show Gist options
  • Save ajtroxell/9349781 to your computer and use it in GitHub Desktop.
Save ajtroxell/9349781 to your computer and use it in GitHub Desktop.
RazorScript for "x" amount of items from Form and List
@using System.Data;
@using DotNetNuke.Entities.Modules;
@using DotNetNuke.Entities.Portals;
@using DotNetNuke.Modules.UserDefinedTable;
@using DotNetNuke.Entities.Users;
@{
var mc = new ModuleController();
var tc = new DotNetNuke.Entities.Tabs.TabController();
int portalId = PortalController.GetCurrentPortalSettings().PortalId;
var flModule = mc.GetModuleByDefinition(portalId, "Form and List");
int moduleId = -1;
int tabId = -1;
// form and list module name
var tab = tc.GetTabByName("News", portalId);
if (tab != null) {
tabId = tab.TabID;
}
// form and list module ID
if (flModule != null) {
moduleId = 968;
}
var ds = (new UserDefinedTableController(moduleId, tabId, new UserInfo())).GetDataSet(true);
int i = 0;
}
<ul>
@foreach (DataRow row in ds.Tables["Data"].Rows)
{
if (i<3)
{
<li>
<a href='/news#@row["UserDefinedRowId"]' title='@row["Title"]'>@row["Title"]</a>
</li>
i++;
}
}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment