-- ********************************************************** -- SQL Server 2000 Edition of database script with content. -- SubSonic StarterKit v2.01 -- Version 1.00 -- ********************************************************** SET NOCOUNT ON -- Remove old tables IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_NAME='CMS_Page') Begin ALTER TABLE CMS_Page DROP CONSTRAINT PK_CMS_Page; DROP TABLE CMS_Page; END IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND TABLE_NAME='CMS_Content') Begin ALTER TABLE CMS_Content DROP CONSTRAINT PK_Content; DROP TABLE CMS_Content; END -- Create tables CREATE TABLE dbo.CMS_Content ( ContentID int IDENTITY(1,1) NOT NULL, ContentGUID uniqueidentifier NOT NULL DEFAULT (newid()), Title nvarchar(500) NULL, ContentName nvarchar(50) NOT NULL, Body ntext NULL, Locale nvarchar(7) NOT NULL DEFAULT (N'en-US'), CreatedOn datetime NULL DEFAULT (getdate()), CreatedBy nvarchar(50) NULL, ModifiedOn datetime NULL DEFAULT (getdate()), ModifiedBy nvarchar(50) NULL ); CREATE TABLE dbo.CMS_Page ( PageID int IDENTITY(1,1) NOT NULL, Title nvarchar(500) NOT NULL, Body ntext NULL, Locale char(5) NOT NULL DEFAULT ('en-US'), ParentID int NULL, PageGuid uniqueidentifier NOT NULL, MenuTitle nvarchar(50) NOT NULL, Roles nvarchar(500) NOT NULL DEFAULT (N'*'), Summary nvarchar(500) NULL, PageUrl nvarchar(500) NOT NULL, Keywords nvarchar(500) NULL, CreatedOn datetime NOT NULL DEFAULT (getdate()), CreatedBy nvarchar(50) NULL, ModifiedOn datetime NOT NULL DEFAULT (getdate()), ModifiedBy nvarchar(50) NULL, Deleted bit NOT NULL DEFAULT ((0)) ); -- Insert Data SET IDENTITY_INSERT dbo.CMS_Content ON; INSERT INTO dbo.CMS_Content(ContentID, ContentGUID, Title, ContentName, Body, Locale, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy) VALUES(4, '475FCF25-A5C4-496A-8E97-2E6A2F4F033D', NULL, N'Porky''s Thinking of BeefContent', N'
Recursion is one of those geek Camaro-qualities, where Big Guy Geek might say "well you know MY recursive method only uses the stack and has 16-inch centerlines" (or something like that). I remember sitting in my Pascal class and our class was on outputting an org chart. Now in those days you handed your work in from a green and white-striped line printer :). Anyway, the prof always gave the person with the fewest lines of code a 10-point bonus.
So I thought I was pretty good at Pascal. I liked it a lot better than basic cause, well, in MY mind it was all about top-down design :). When all was said and done the Big Guy Geek who got the extra credit (umm, not me) had about 10 times less code than I did. And 16-inch centerlines. All through the lovely use of recursion. It''s never come easy to me, but from time to time I''m able to pull it off. This was NOT one of those times - the bits below come from here.
Recursion Sucks. Recursion Rules.
So I have a need to do something simple: represent a self-referencing table in a nice, human-readable way:
', N'en-US', '20070507 16:35:31', N'admin', '20070507 16:49:55', N'admin');
INSERT INTO dbo.CMS_Content(ContentID, ContentGUID, Title, ContentName, Body, Locale, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy)
VALUES(10, 'BC675996-5F6C-4D1D-A511-0F9B10737AD5', NULL, N'termsofuse', N'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam faucibus arcu sed lectus. Vestibulum feugiat felis quis libero. Donec feugiat leo id urna. Aliquam vel quam. Morbi nunc ante, vehicula at, eleifend sit amet, pharetra non, lectus. Cras pharetra nulla a diam. Mauris bibendum interdum tortor. Aenean et arcu ac pede vestibulum consequat. Aliquam nulla. Quisque posuere. Vivamus nunc. Curabitur ac velit a massa ornare auctor. Donec condimentum dictum dui. Nullam tellus leo, porta vel, vestibulum a, pellentesque at, nulla.
Duis non velit vel sapien commodo cursus. Donec non eros. Nulla facilisi. Ut erat mi, euismod at, commodo sed, suscipit non, nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum nec tortor sed dui interdum consectetuer. Vestibulum pellentesque ullamcorper turpis. Nulla rutrum pellentesque est. Etiam elementum. Sed dolor sem, fermentum ut, posuere nec, lobortis eu, eros. Curabitur magna elit, ullamcorper nec, malesuada in, consequat a, elit. Curabitur pharetra mollis tortor. Aenean neque purus, lacinia ut, eleifend sit amet, malesuada et, tellus. Donec eget purus vel pede hendrerit dapibus. Duis facilisis. Nulla aliquet. Sed est.
Curabitur magna tellus, congue bibendum, iaculis id, luctus vel, nulla. Nam imperdiet quam id urna. Cras eget tellus. Phasellus ornare. Praesent auctor consectetuer elit. Morbi vel lectus nec odio congue vulputate. Nullam dignissim purus eu nibh. Donec massa libero, pulvinar ac, venenatis a, tincidunt et, sem. Phasellus placerat tellus ut sapien. Vivamus dictum erat. Cras pellentesque, mauris ac molestie mattis, ipsum leo iaculis magna, ut pellentesque sapien nisi feugiat dolor. Phasellus ac augue. Sed fringilla faucibus ante. Vivamus commodo venenatis neque. Sed nisl. Vestibulum tristique posuere velit. Donec ullamcorper posuere tellus. Integer elit mi, placerat sit amet, volutpat quis, tempus eget, odio. Donec augue. Maecenas dolor est, hendrerit lobortis, lacinia sed, hendrerit a, ligula.
Fusce neque massa, porttitor et, commodo eget, consectetuer euismod, sapien. Donec a enim nec pede ultrices blandit. Morbi sit amet dolor imperdiet dolor ultrices luctus. Mauris dictum, tortor non bibendum dignissim, risus elit condimentum erat, sed mollis nunc lorem in quam. Vestibulum malesuada rhoncus metus. Phasellus est. Donec ultrices. Donec nulla nisi, blandit non, laoreet vitae, ultrices id, eros. Proin orci est, blandit venenatis, volutpat sit amet, fermentum eget, ante. Sed arcu. Maecenas auctor libero nec lectus. Vivamus luctus diam id dui. Sed accumsan metus. Cras felis libero, adipiscing nec, mattis at, condimentum sit amet, nisl. Nam sed nisi. Vestibulum laoreet purus a magna. Integer tempor nisl nec ante. Ut euismod enim condimentum pede.
Sed justo. Nullam accumsan porttitor massa. Donec nec augue vitae velit malesuada tempor. Aliquam elit nisi, tempor rutrum, accumsan quis, placerat ut, magna. Donec blandit. Aliquam eu dui ut felis scelerisque feugiat. Sed nisl pede, elementum ac, feugiat at, ornare tincidunt, nunc. Ut eu lacus. Suspendisse felis nisl, euismod scelerisque, faucibus mattis, pulvinar ut, velit. Cras eu libero id orci condimentum tincidunt. Nullam felis. Nullam nibh est, gravida eu, tempor eu, varius sed, est. Vivamus suscipit elit. Quisque eget velit. Cras rhoncus lectus egestas arcu. Duis aliquet lacus id enim. Nullam id lectus. Praesent dictum posuere tellus.
The SubSonic Starter Site is designed to help you get your ideas up quickly. We try to do the legwork for you, including:
Want to know more? Watch this webcast!
If you have any questions, please feel free to ask us at our forums: http://actionpack.wekeroad.com.Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec eu mauris. Sed nulla. Sed turpis purus, rhoncus quis, commodo eu, bibendum ac, quam. Etiam eu pede. Maecenas sagittis aliquet velit. Integer fringilla. Aenean et tellus sed nibh fermentum sodales. Cras ac velit. Quisque tortor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla ut arcu et justo tincidunt dignissim. Proin elementum, magna eu condimentum tempor, neque diam eleifend tortor, sit amet vehicula quam massa sed tellus. Praesent pulvinar convallis lorem. Quisque arcu risus, euismod vel, cursus vitae, blandit sed, ipsum. Aliquam erat volutpat.
Donec nisi augue, condimentum vel, iaculis ac, vestibulum sed, dolor. Praesent ipsum arcu, accumsan quis, faucibus id, vulputate vitae, felis. Morbi quis purus. Nam ac urna. Nullam auctor auctor lectus. Duis accumsan turpis id orci. Aenean felis velit, luctus eget, hendrerit id, tincidunt ac, urna. Donec porta. Aliquam sagittis. Fusce sed purus. Sed ultricies nibh id arcu. Vestibulum quis felis vel mauris iaculis sollicitudin.
Duis sed dolor. In hac habitasse platea dictumst. Mauris ipsum. Curabitur ut neque sed magna lobortis sodales. Vestibulum tellus. Sed leo. Nulla sit amet pede mattis lectus fringilla gravida. Maecenas non ante ut ipsum tristique consequat. Sed malesuada feugiat urna. In ut felis a leo tristique pellentesque. Aenean quis enim. Nam pellentesque, purus sed iaculis elementum, lorem nisl placerat massa, sed lacinia tortor ipsum sed sapien. Pellentesque sit amet odio. Aenean suscipit nulla eget quam. Vestibulum et elit ac orci sagittis tincidunt.
Donec imperdiet est eu tortor. Donec lacinia, nisi non interdum gravida, magna mauris dignissim mi, at posuere justo leo eget arcu. Pellentesque luctus urna sit amet erat. Nullam nisi leo, sagittis a, rhoncus quis, posuere ut, enim. Phasellus a est id augue fermentum euismod. Donec arcu. Donec arcu. Vivamus eu sem. Morbi aliquam tristique felis. Proin tincidunt fringilla diam. Quisque lacinia viverra neque. Proin pede. Nulla nonummy lorem sit amet magna. Nulla vestibulum ultrices lacus. Aenean quis lorem et arcu lobortis semper.
Sed nunc. Aenean quis leo sit amet ipsum tincidunt pharetra. Nunc vel nulla at leo sagittis interdum. Vestibulum lobortis, justo vitae lacinia dapibus, lorem diam scelerisque massa, id pretium erat nulla in mi. Morbi risus. Praesent lacinia dolor et est. Duis et velit. Mauris turpis urna, fermentum at, gravida non, fermentum in, ipsum. Aenean blandit gravida felis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
You will immediately notice, if you''ve used other CMS systems, that we don''t have versioning built in. This is by choice as we want to try to make this as simple a system as possible and, frankly, versioning might not be needed in all cases.
Dynamic Pages
This is a dynamic page, and you can edit it right here if you log in as "admin" with the password "admin". In fact all the pages in the menu above are dynamic (meaning they don''t really exist - they''re just database-driven pages that are written out with UrlRewriting). You can change the hierarchy around as you need, assign keywords, change summaries -and so on. It''s all up to you. Login as "admin" and head back over to see what kind of damage you can do.
If you want to change the menu around, you can do that in site.master.cs. In there you will see how we add in the Admin menuing for administrators on the fly.
FCK Editor
You''ll notice when you go to edit any of the CMS content that we use the FCK Editor. This thing is very powerful (and also big!) and allows you to do a level of file management as well. All files that you upload using the FCK Editor go into the CMSFiles directory - you have to make sure this has write privileges for your ASP identity.
You can change this for your users, if you want to allow them to load files into their own (or another directory). To get this to work, you''ll need to add a routine to the top of your page or User Control:
protected void Page_Init(object sender, EventArgs e){
txtContent.SkinPath = "skins/office2003/";
Session["FCKeditor:UserFilesPath"] = Page.ResolveUrl("~/CMSFiles");
}
There are some things you need to make sure you do to make this work properly on your site (in other words, don''t kill these files or lines of code):
SiteMaster: you''ll notice an INCLUDE directive right at the end of the page:
<!--#INCLUDE File=js/modal/modal_divs.aspx-->This file holds the div tags that need to be present for the modal windows to work. If you move these or delete them, the page will be messed up. You''ll want to leave them right where they are.
You''ll also notice in the code behind file of site.master, we are dynamically adding a reference to the CSS files for the modal window:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) {
Head1.Controls.Add(new LiteralControl("<script type=''text/javascript'' src=''" + Page.ResolveUrl("~/js/modal/common.js") + "''></script>"));
Head1.Controls.Add(new LiteralControl("<script type=''text/javascript'' src=''" + Page.ResolveUrl("~/js/modal/subModal.js") + "''></script>"));
...
}
}
Again, you don''t want to change this.
This is my page text...
', 'en-US', 6, '43805595-5625-4ED0-8EEB-FB6A091F7A44', N'New Page', N'*', N'This is my summary, which will appear right below the title', N'my-new-page---check-me-out.aspx', N'Keywords...', '20070510 09:59:12', N'admin', '20070510 14:38:43', N'admin', 1); INSERT INTO dbo.CMS_Page(PageID, Title, Body, Locale, ParentID, PageGuid, MenuTitle, Roles, Summary, PageUrl, Keywords, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy, Deleted) VALUES(32, N'asd', N'sad', 'en-US', 5, '0818A840-AEB4-437F-94CC-F94D74F8122D', N'sad', N'*', N'asd', N'asd_2.aspx', N'', '20070510 14:51:55', N'admin', '20070510 14:54:50', N'admin', 1); INSERT INTO dbo.CMS_Page(PageID, Title, Body, Locale, ParentID, PageGuid, MenuTitle, Roles, Summary, PageUrl, Keywords, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy, Deleted) VALUES(33, N'asdasd', N'asd', 'en-US', NULL, '3E84CEAD-94BE-45FC-85D4-014566FCDBD4', N'asdasd', N'*', N'asd', N'asdasd.aspx', N'asd', '20070510 14:55:11', N'admin', '20070510 14:56:11', N'admin', 1); INSERT INTO dbo.CMS_Page(PageID, Title, Body, Locale, ParentID, PageGuid, MenuTitle, Roles, Summary, PageUrl, Keywords, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy, Deleted) VALUES(34, N'asd', N'asdasdasd', 'en-US', 33, 'E03585B7-35CA-4CA8-82D2-5B8F839E5A5F', N'sad', N'*', N'sad', N'asd.aspx', N'sad', '20070510 14:55:22', N'admin', '20070510 14:56:01', N'admin', 1); SET IDENTITY_INSERT dbo.CMS_Page OFF; -- Set up constraints ALTER TABLE dbo.CMS_Content ADD CONSTRAINT PK_Content PRIMARY KEY (ContentID); ALTER TABLE dbo.CMS_Page ADD CONSTRAINT PK_CMS_Page PRIMARY KEY (PageID); -- Return database to normal state SET NOCOUNT OFF