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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0how to dynamically add a page to a sitehow to dynamically add a page to a site
Previous
 
Next
New Post
8/28/2006 10:49 AM
 
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
 
New Post
8/29/2006 11:06 AM
 
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
 
New Post
9/1/2006 9:55 AM
 
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
 
New Post
9/2/2006 11:08 PM
 
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
 
New Post
9/11/2006 7:46 AM
 
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
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0how to dynamically add a page to a sitehow to dynamically add a page to a site


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