Hi Peterg,
of course you can programatically create pages and generally you are on the right track but here are the few more tips so you can create everything without a problem.
1. Iterate through the list of your files / pages and with the program you have copy (or create) the files (as you mentioned " My_File_Name.aspx") - be sure that created or copied file contains the proper mark-up, you can find an example of proper mark-up (of empty page) in "/App_Templates/Default/PageTemplates/DefaultTemplate.aspx" which contains the columns template with two zones and document editors (so you can add the content you want)
2. Insert a record for every page you create to "Page" and set the title of the page in "PageLocalization" (as you have mentioned)
3. If you want to insert default content (that can be dynamically changed) in these files then you need to insert content in MonoX Editors (placed in the Zones mentioned above). There are two ways that you can to this:
3.1 Insert default content by parsing the file and place the content in DefaultContent inside the Editor (example is below)
<
MonoX:Editor
runat
=
"server"
ID
=
"editor1"
Title
=
'Left section'
DefaultDocumentTitle
=
'Left section'
>
<
DefaultContent
>
<
h2
>Content Management</
h2
>
<
img
src
=
"/App_Themes/Default/img/content-management-icon.png"
alt
=
"Content management"
/>
<
div
>
Inspired by the latest Web technologies and built on top of the Web parts infrastructure,
MonoX allows you to design and develop next generation ASP.NET Web
portals and applications. It features an intuitive, user-friendly user interface that supports Web parts framework,
drag and drop, WYSIWYG interface, content versioning, advanced security model, cross-browser support,
advanced templating engine and multi-level personalization.
<
ul
>
<
li
><
a
href
=
"/MonoX/Pages/Features.aspx"
>>> Features</
a
> </
li
>
<
li
><
a
href
=
"/MonoX/Pages/AdditionalResources.aspx"
>>> Related resources</
a
> </
li
>
<
li
><
a
href
=
"/MonoX/Pages/News.aspx"
>>> News</
a
> </
li
>
<
li
><
a
href
=
"/MonoX/Pages/SocialNetworking/EventCalendar.aspx"
>>> Calendar</
a
> </
li
>
<
li
><
a
href
=
"/ContentPage/ChangeLog/"
>>> Change log</
a
> </
li
>
</
ul
>
</
div
>
</
DefaultContent
>
</
MonoX:Editor
>
3.2 You can insert / create the document programatically by inserting records to MonoX "Document" table
Every programmatic operation can be done by using the MonoX repository layer and here are the few samples:
Create a document
DocumentRepository.GetInstance().CreateNewDocument(DefaultDocumentTitle, DefaultContent, ContentId, InstanceOfTheEditorPart, PageId)
Create a document version 2
DocumentEntity document =
new
DocumentEntity(GuidExtension.NewSequentialGuid());
document.RevisionVersion =
false
;
document.BackupVersion =
false
;
document.PageId = pageId;
document.ControlId = PageUtility.GetControlPersonalizationKey(editorInstance);
if
(!
string
.IsNullOrEmpty(contentId))
document.ContentId = contentId;
document.LanguageId = LocalizationUtility.GetCurrentLanguageId();
document.TextContent = content;
if
(!GuidExtension.IsNullOrEmpty(SecurityUtility.GetUserId()))
document.UserId = SecurityUtility.GetUserId();
document.DateModified = DateTime.Now;
document.Title = title;
DocumentRepository.GetInstance().SaveEntity(document,
true
);
My suggestion will be to insert the default content by parsing the file (simple string replace would do the job) because in some cases it is hard to get the instance of the editor to create the document.
I hope this will help you find the best way to accomplish the task at hand.
Regards.