Geego cms - content mangement system - website management

Tutorial - Hike On, part 3

Create the news template definition Create the news page and enter content Create the news view Add news to the menu Finished for now

Create the news template definition

        top of page

Create a new template definition called /geego/news.rb with the following code

{:name=>'r_news_items', :fields=>['tm_Title', 'dt_Date', 'tl_Article', {:name=>'img_Photo', :width=>200}]}

Note we are automatically setting all photos to 200px rather that letting the client set the photos size themselves.

Add the template definition to the template list with a type of page.

Create the news page and enter content

        top of page

Add a new page called /news using the template.

Edit the content creating various news items as you see fit.

Create the news view

        top of page

Create the view /app/views/g_pub/news.rhtml with the following code

<h1><%= @g[:page_title] %></h1>

<table>
<%
for item in @g[:news_items]
    %>   
    <tr>
        <td>
                <h2><%= item[:title] %></h2>
                <%= image_tag item[:photo][:show], :style=>"float: right" %>
                <p style="font-style: italic"> <%= item[:date].strftime("%d-%m-%Y") %></p>
                <p> <%= item[:article] %></p>
        </td>   
    </tr>
    <%
end
%>
</table>

Add news to the menu

        top of page 340

Publish /news

and then edit content for /main_menu and add an item to the principal menu items with a text of News and linking to our newly created news page.

Publish main_menu.

Finished for now

        top of page

We now have a basic information website setup with a heirachical menu, unlimited news items and the ability to add muliple images & new pages.

In the next tutorial we will publish news items to their own model/table so that we can search them and generally have more flexiibilty in their display.