| |
|
|
|
|
|
|
|
|
|
 |    |  |
 | |  |
 | |  |
 | |  |
 | |  |
 |
|
|
| how to dynamically add a page to a site |
|
|
Hello all, I am developping a news module which must have the ability to post a news item on multiple sites. Upon creating the news item, the user decides which site the item is to appear on. What I have so far, the module :
- stores all data in the database,
- successfully 'views' or displays the news item iff the user chose to have the news item appear on that particular site.
In the view page, the module shows a Title and short description for the news article. A "Read more..." link must bring the user to the actual article's page related to this item. My problem I need to find a way to dynamically create the page on which the main article is to appear. This page must be created on all sites on which the user wants it to appear when the the news item was created. Needless to say that it would be unacceptable to have the user create the page for the article in question on all, say four sites, on which the item will appear. My question is as follows: How can I dynamically "add a page" to a site, or multiple sites, which would also include dynamically creating its title and content, from the module's edit page. I appreciate anyone's help, and I am more than willing to elaborate on my problem, or clarify on its issues. Thanks in advance! Caley
|
|
|
|
 |  |
|
|
| Re: how to dynamically add a page to a site |
|
|
OK, I thought I'd follow up with my improvements on the matter in case anyone will EVER want to attempt what I'm trying to do.
After realizing that DNN's data provider model refers to 'pages' as 'Tabs', i can see that the Tabs table in the portal's database is updated with all the settings the page was given upon its creation. Each tab, or page, is given a unique id called TadId, along with 20 other properties such as TabName, IsVisible, Title, Description, Keywords etc... Therefore, in order to add a page to the site, I will simply add another item to this table.
Great. Now, I THINK that I have 'created' a page, but in order to give this page a purpose, I need to do two more things: first, dynamically insert an HTML/text module which will contain the title and Article, secondly create a link to it. Returning to the app's database and looking at the ModuleDefinitions table, we see that DNN refers to each installed module with this table's primary key, ModuleDefID. The HTML/TEXT's ModuleDefId is 109.
At this point, the application needs to keep track of the different instances of these modules which appear on different pages, huhm, tabs. This is where the TabModules table comes in: We see that it links ModuleId and TabId, the two primary keys from the Modules and Tabs table, respectively.
Therefore, to add a page to the DNN site, one must add to the Tabs, Modules, and TabModules tables.
I still haven't figured out how to create a link such that DNN will automatically look at these tables and generate the page. Also, I noticed that the Modules table only contains records of the module's Title and not the content of the HTML/Text portion. Where is the content of this module saved? Caley
|
|
|
|
 |  |
|
|
| Re: how to dynamically add a page to a site |
|
|
Am I completely off with my technique of adding a page dynamically? Can anyone offer me input/feedback so that I feel as though I'm actually going to accomplish this feat? Please, if anyone knows of an easier way to add a page using code, I'm all ears. Caley
|
|
|
|
 |  |
|
|
| Re: how to dynamically add a page to a site |
|
|
Have you looked at the DotNetNuke.Entities.Tabs.TabController.AddTab metnod? This mthod allows you to create page. Robert Tango
www.workcontrol.com Custom Modules:
UserManager|UserDirectory|UserImport|PortalSSO
|
|
|
|
 |  |
|
|
| Re: how to dynamically add a page to a site |
|
|
The following code did the trick.
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[CIP_GenerateCIPNews] @ModuleId int, @Title varchar(150), @Description varchar(1000), @Article varchar(8000), @PostStartDate datetime, @PostEndDate datetime, @PortalId int, @CreatedByUser int, @CreatedDate datetime
AS
DECLARE @AdministratorId int SET @AdministratorId = 2 DECLARE @TabId int DECLARE @TabViewPermissionId int DECLARE @TabEditPermissionId int DECLARE @AdminRoleId int
DECLARE @CIPNewsModuleDefId int DECLARE @CIPNewsModuleId int DECLARE @HTMLModuleDefId int DECLARE @HTMLModuleId int DECLARE @ModuleViewPermissionId int DECLARE @ModuleEditPermissionId int
INSERT INTO CIPNews ( ModuleId, Title, Description, PostStartDate, PostEndDate, PortalId, CreatedByUser, CreatedDate ) VALUES ( @ModuleId, @Title, @Description, @PostStartDate, @PostEndDate, @PortalId, @CreatedByUser, getdate() ) -- Get the identity of newly added CIPNews item SELECT @CIPNewsModuleId = SCOPE_IDENTITY()
-- Get the Module Definition for the CIPNews Module SELECT @CIPNewsModuleDefId = ModuleDefId FROM ModuleDefinitions WHERE FriendlyName='CIPNews'
-- Get the Module Definition for the HTMLNews Module SELECT @HTMLModuleDefId = ModuleDefId FROM ModuleDefinitions WHERE FriendlyName='Text/HTML'
-- Create a new instance of the HTML/Text Module, return primarykey in @HTMLModuleId INSERT INTO Modules ( PortalId, ModuleDefId, ModuleTitle, AllTabs, Header, Footer, StartDate, EndDate, InheritViewPermissions, IsDeleted ) VALUES ( @PortalId, @HTMLModuleDefId, @Title, 0, null, null, null, null, 1, 0 ) SELECT @HTMLModuleId = SCOPE_IDENTITY()
-- Insert Article into HTML/Text Module Instance INSERT INTO HTMLText ( ModuleID, DesktopHtml, DesktopSummary, CreatedByUser, CreatedDate ) VALUES ( @HTMLModuleId, @Article, @Title, @CreatedByUser, @CreatedDate )
--create a new Tab for the conversion INSERT INTO Tabs ( PortalId, TabName, IsVisible, DisableLink, ParentId, IconFile, Title, Description, KeyWords, IsDeleted, Url, SkinSrc, ContainerSrc, TabPath, StartDate, EndDate ) values ( @PortalId, @Title, 0, 0, null, '', @Title, '', '', 0, '', null, null, '//CIPNews', @CreatedByUser, @CreatedDate )
SELECT @TabId = SCOPE_IDENTITY()
-- Get the administrator roleid SELECT DISTINCT @AdminRoleId = RoleId FROM Roles WHERE RoleName = 'Administrators' AND PortalId = @PortalId
-- Get the Permission IDs for the Tab & Module SELECT DISTINCT @TabViewPermissionId = PermissionId FROM Permission WHERE PermissionCode = 'SYSTEM_TAB' AND PermissionKey = 'VIEW'
SELECT DISTINCT @TabEditPermissionId = PermissionId FROM Permission WHERE PermissionCode = 'SYSTEM_TAB' AND PermissionKey = 'EDIT'
SELECT DISTINCT @ModuleViewPermissionId = PermissionId FROM Permission WHERE PermissionCode = 'SYSTEM_MODULE_DEFINITION' AND PermissionKey = 'VIEW'
SELECT DISTINCT @ModuleEditPermissionId = PermissionId FROM Permission WHERE PermissionCode = 'SYSTEM_MODULE_DEFINITION' AND PermissionKey = 'EDIT'
--Add View permissions for the Tab INSERT INTO TabPermission (TabId,PermissionId,RoleId,AllowAccess) VALUES (@TabId,@TabViewPermissionId,@AdminRoleId,1)
--Add Edit permissions for the Tab INSERT INTO TabPermission (TabId,PermissionId,RoleId,AllowAccess) VALUES (@TabId,@TabEditPermissionId,@AdminRoleId,1)
--Add View permissions for the Module INSERT INTO ModulePermission (ModuleId,PermissionId,RoleId,AllowAccess) VALUES (@HTMLModuleId,@ModuleViewPermissionId,@AdminRoleId,1)
--Add Edit permissions for the Module INSERT INTO ModulePermission (ModuleId,PermissionId,RoleId,AllowAccess) VALUES (@HTMLModuleId,@ModuleEditPermissionId,@AdminRoleId,1)
--add the HTML/Text Module to the Tab INSERT INTO TabModules ( TabId, ModuleId, PaneName, ModuleOrder, CacheTime, Alignment, Color, Border, IconFile, Visibility, ContainerSrc, DisplayTitle, DisplayPrint, DisplaySyndicate ) VALUES ( @TabId, @HTMLModuleId, 'ContentPane', 1, 0, null, null, null, null, 0, null, 1, 0, 0 ) Thanks to John Mitchell's blog
|
|
|
|
|  |
 | |  |
 | |  |
 | |  |
|  |
| |
 |
|
These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.
For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.
|
| |
 |
|
|
|
|
|
|
|