我正在使用DNN API创建页面,如下所示:
public int AddPage(string name, string title, string url, int parentPageID = 0)
{
TabController pageManager = new TabController();
TabInfo newPage = new TabInfo();
newPage.PortalID = _PortalID;
newPage.TabName = name;
newPage.Title = title;
newPage.ParentId = parentPageID;
newPage.SkinPath = "/path-to-skin";
newPage.SkinSrc = "/path-to-skin/skin-name.ascx";
int newPageID = pageManager.AddTab(newPage);
TabUrlInfo tabUrlInfo = new TabUrlInfo();
tabUrlInfo.TabId = newPageID;
tabUrlInfo.Url = url;
tabUrlInfo.HttpStatus = "200";
tabUrlInfo.SeqNum = 1;
newPage.TabUrls.Add(tabUrlInfo);
pageManager.UpdateTab(newPage);
var parentPage = GetPage(parentPageID);
_AddDDRMenuToPage(newPageID, parentPage.TabName);
return newPageID;
}
TabUrlInfo方法没有影响,newPage.Url将页面设置为链接。 我想改变的属性是:
知道我哪里出错了吗?
修改
通过使用以下代码行,我更进了一步:
PageManager.SaveTabUrl(tabUrlInfo, _PortalID, true);
这取代了这两行:
newPage.TabUrls.Add(tabUrlInfo);
pageManager.UpdateTab(newPage);
使用SaveTabUrl正确保存TabUrls表中的记录但是当我尝试转到页面设置时出现404错误?
答案 0 :(得分:0)
您可以使用TabController
> SaveTabUrl
。这是DNN 7.3及以上版本。
//create a new tabcontroller instance
TabController controller = new TabController();
//create a new tab with some properties
TabInfo newTab = new TabInfo();
newTab.PortalID = 0;
newTab.TabName = "TabNaam";
newTab.Title = "TabTitel";
//add the new tab and get it's new tabid
int newTabId = controller.AddTab(newTab);
//create a new taburlinfo insance and set some propeties
TabUrlInfo tabUrl = new TabUrlInfo();
tabUrl.TabId = newTabId;
tabUrl.SeqNum = 0;
tabUrl.Url = "/dit-is-een-test";
tabUrl.HttpStatus = "200";
//save the url info
controller.SaveTabUrl(tabUrl, PortalId, true);