Geego cms - content mangement system - website management

Displaying shared portions

About shared portions

Shared portions contain content that is shared accross multiple pages. Typical examples of shared portions are menus, footers, contact info at top of page or any general layout text or images that you wish to make editable.

They are created modified and published in exactily the same way as a page.

When you add a template definition to the list of templates you can give it a type of Page or Shared portion. When you click on new shared portion you will be able to use any templates with a type of Shared portion.

Displaying shared portions.

In the default setup the GPubHelper helper has a method called share_include that displays shared portions. (It is a very simple bit of code that is worth a look so you know what is happening).

share_include(location, name[, has_view=true])

Shared include takes 2 to 3 parameters. Location and name of shared portion and an optional parameter has_view, whether or not it has a view. If you set has_view to false the shared portions contents will only be appended to @g for later use and not displayed.

If the shared portion does have a view it will need to be created as a partial template ie. file name prepended with '_'.

Examples:

Displaying a simple 1D menu in the layout template.

The code in the layout template is:

<div class="menu_box" style="height: 27px; text-align: center">
  <%= share_include('/', 'main_menu') %>
</div>


The code in _main_menu.rhtml is:

<%
@g[:main_menu].each do |item|
  %>
  <%= link_to item[:link][:show], "#{item[:link][:address]}/#{@language_id}" %>
  <%
end
%>



Displaying some footer text at the bottom of each page.

<div class="footer_box" style="height: 27px; text-align: center">
  <p>
    <%= share_include('/', 'page_footer') %>
  </p>
</div>


The code in _page_footer.rhtml is:

<%= @g["tl_Footer_text"] %>