Building a Content Managed Site with EngineY

timothyf edited this page Sep 13, 2010 · 21 revisions

EngineY is not only useful for building social networking sites. EngineY also makes a great platform for building any site in which you want to easily be able to manage its content through a simple UI. For example, the EngineY home page at www.enginey.com doesn’t look at all like a social site, however it is running on EngineY. Each piece of content on that site is editable through the UI. This allows me to quickly and easily make updates and changes to the site. You can also start with a content managed site and slowly add in some of EngineY’s social features.

Creating a sample CMS site
EngineY includes a Rake task that can be used to generate a sample content managed site that you can then modify to meet your unique requirements. To setup this sample CMS site follow these steps:

   rake db:drop:all (remove any existing databases)
   rake db:create:all
   rake db:migrate
   rake enginey:cms_site_init

This will create a site for you with 4 pages, Home, About, Products, and Team. Each of these pages contains managed content sections allowing you to edit any of the site’s content without having to touch source code. To view the edit links for the site content you have to be logged into the site as an admin. The rake task created an admin user for you with the username admin and the password admin. Login by going to: http://localhost:3000/login.
Then return to your homepage, http://localhost:3000 and you should see Edit links below each of the managed content sections. The home page contains 3 managed content sections. One on the left for navigation, a main content section, and two content sections occupyingg the center part of the page.

To understand how this site is built, you should review the code in /lib/tasks/cms_site_init.rake
and the theme for this site found in /themes/cms_site_sample

Understanding how the content is setup in cms_site_init.rake
In the cms_site_init.rake file pay particular attention to how these objects are created, Page, HtmlContent, Widget, and WidgetLayout. You will see that we create 4 pages, home, about, products, and team. After the Pages are created, we create the Widget that we will use. We only require a single widget, which is the html_content_home widget. This is the widget which is used to display managed content.

Next we create the HtmlContent objects that we will need. The HtmlContent objects hold chunks of HTML that will be displayed on a page. Each page will have a simple layout of a navigation section on the left and a main content section on the right. All of the pages will share common navigation content, so we only need one HtmlContent for the navigation. Each page will have their own main content HtmlContent element. So we have 5 total HtmlContent objects being created.

Finally, we setup the layout of which HtmlContent elements will go on which pages. This is done by creating WidgetLayout objects. Each page requires two WidgetLayout objects, one for the navigation object, and one of the page’s main content object. Notice that for each page the navigation layouts all use the same html_content_id of 1 which is the common HtmlContent for the navigation. Specifying col_num = 1 for the navigation object and col_num = 2 for the main content element for each page will insure that the elements are placed in different divs allowing us to achieve the desired side-by-side layout with a stylesheet.