diff --git a/cms/src/kernel/link/cms_menu_system.e b/cms/src/kernel/link/cms_menu_system.e index 81948f5..470aba3 100644 --- a/cms/src/kernel/link/cms_menu_system.e +++ b/cms/src/kernel/link/cms_menu_system.e @@ -20,9 +20,9 @@ feature {NONE} -- Initialization do to_implement ("Refactor, take the info from a Database or Configuration file.") create items.make (5) - force (create {CMS_MENU}.make ("main-menu", 3)) -- primary menu - force (create {CMS_MENU}.make_with_title ("management", "Management", 3)) -- secondary in admin view. - force (create {CMS_MENU}.make_with_title ("navigation", "Navigation", 3)) -- secondary + force (create {CMS_MENU}.make ("primary_nav", 3)) -- primary menu + force (create {CMS_MENU}.make_with_title ("management_nav", "Management", 3)) -- secondary in admin view. + force (create {CMS_MENU}.make_with_title ("secondary_nav", "Navigation", 3)) -- secondary force (create {CMS_MENU}.make_with_title ("user", "User", 3)) -- first_side_bar end @@ -42,17 +42,17 @@ feature -- Access main_menu: CMS_MENU do - Result := item ("main-menu") + Result := item ("primary_nav") end management_menu: CMS_MENU do - Result := item ("management") + Result := item ("management_nav") end navigation_menu: CMS_MENU do - Result := item ("navigation") + Result := item ("secondary_nav") end user_menu: CMS_MENU diff --git a/cms/src/service/response/cms_response.e b/cms/src/service/response/cms_response.e index e78930f..4564913 100644 --- a/cms/src/service/response/cms_response.e +++ b/cms/src/service/response/cms_response.e @@ -217,10 +217,10 @@ feature -- Blocks set_header_block (a_page: CMS_HTML_PAGE) do if not main_menu.is_empty then - a_page.register_variable (main_menu, "primary_nav") + a_page.register_variable (theme.menu_html (main_menu, False), "primary_nav") end if not navigation_menu.is_empty then - a_page.register_variable (navigation_menu, "secondary_nav") + a_page.register_variable (theme.menu_html (navigation_menu, False), "secondary_nav") end end @@ -314,31 +314,6 @@ feature -- Blocks do create s.make_from_string (theme.menu_html (main_menu, True)) create l_hb.make_empty - to_implement ("Check if the tpl does not exist, provide a default implementation") - if attached {SMARTY_CMS_THEME} theme as l_theme then - create tpl.make ("block/header_test", l_theme) - -- Change to "block/header_block" to use the template code. - create l_page.make - l_page.register_variable (s, "header_block") - tpl.prepare (l_page) - l_hb := tpl.to_html (l_page) - end - if l_hb.starts_with ("ERROR") then - l_hb.wipe_out - to_implement ("Hardcoded HTML with CSS, find a better way to define defaults!!!.") - l_hb := "[ - - ]") - - end create Result.make ("header", Void, l_hb, formats.full_html) Result.set_is_raw (True) end @@ -639,6 +614,9 @@ feature -- Generation call_menu_alter_hooks (menu_system) prepare_menu_system (menu_system) + if attached theme.navigation_template as l_navigation_template then + page.register_variable (l_navigation_template, l_navigation_template) + end set_blocks (page) -- get_blocks -- across @@ -659,16 +637,16 @@ feature -- Generation page.set_title ("CMS::" + request.path_info) end --- -- blocks --- across --- regions as reg_ic --- loop --- across --- reg_ic.item.blocks as ic --- loop --- page.add_to_region (theme.block_html (ic.item), reg_ic.item.name) --- end --- end + -- blocks + across + regions as reg_ic + loop + across + reg_ic.item.blocks as ic + loop + page.add_to_region (theme.block_html (ic.item), reg_ic.item.name) + end + end end common_prepare (page: CMS_HTML_PAGE) diff --git a/cms/src/service/response/home_cms_response.e b/cms/src/service/response/home_cms_response.e index cf51ad9..9cd309c 100644 --- a/cms/src/service/response/home_cms_response.e +++ b/cms/src/service/response/home_cms_response.e @@ -29,7 +29,7 @@ feature -- Execution process -- Computed response message. do - set_title ("Home") + set_title (Void) set_page_title (Void) end end diff --git a/cms/src/theme/cms_theme.e b/cms/src/theme/cms_theme.e index 14b1d9d..6166672 100644 --- a/cms/src/theme/cms_theme.e +++ b/cms/src/theme/cms_theme.e @@ -33,6 +33,12 @@ feature -- Access deferred end + navigation_template: detachable READABLE_STRING_GENERAL + -- navigation template name, if any. + deferred + end + + feature -- Conversion menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8 diff --git a/cms/src/theme/default_theme/default_cms_theme.e b/cms/src/theme/default_theme/default_cms_theme.e index a15cc0d..bab1939 100644 --- a/cms/src/theme/default_theme/default_cms_theme.e +++ b/cms/src/theme/default_theme/default_cms_theme.e @@ -114,6 +114,11 @@ feature -- Conversion Result := html_template.to_html (page) end + navigation_template: detachable READABLE_STRING_GENERAL + -- navigation template name, if any. + do + end + feature {NONE} -- Internal internal_page_template: detachable like page_template diff --git a/cms/src/theme/smarty_theme/smarty_cms_theme.e b/cms/src/theme/smarty_theme/smarty_cms_theme.e index 1eb14f1..3576623 100644 --- a/cms/src/theme/smarty_theme/smarty_cms_theme.e +++ b/cms/src/theme/smarty_theme/smarty_cms_theme.e @@ -74,6 +74,12 @@ feature -- Access Result := tpl end + navigation_template: detachable READABLE_STRING_GENERAL + -- navigation template name, if any. + do + Result := information.item ("navigation") + end + feature -- Conversion menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8 @@ -83,13 +89,7 @@ feature -- Conversion tpl: SMARTY_CMS_PAGE_TEMPLATE l_page: CMS_HTML_PAGE do - to_implement ("Proof of concept to load a Menu from a tpl/menu.tpl.") - to_implement ("In this case the template only take care of links.") - to_implement ("Maybe we need a SMARTY_CMS_REGION_TEMPLATE") - to_implement ("Provide a default Menu using HTML hardcoded, maybe using the Default or providing a default implementation in CMS_THEME.menu_html") - -- Use the similar pattern to SMARTY_CMS_PAGE_TEMPLATE, with a different prepare - -- feature - create tpl.make ("tpl/menu", Current) + create tpl.make ("tpl/" + a_menu.name, Current) create l_page.make l_page.register_variable (a_menu, "menu") tpl.prepare (l_page) diff --git a/examples/roc_api/site/www/themes/bootstrap/page.tpl b/examples/roc_api/site/www/themes/bootstrap/page.tpl index 7f32495..853a611 100644 --- a/examples/roc_api/site/www/themes/bootstrap/page.tpl +++ b/examples/roc_api/site/www/themes/bootstrap/page.tpl @@ -33,7 +33,7 @@ diff --git a/examples/roc_api/site/www/themes/bootstrap/theme.info b/examples/roc_api/site/www/themes/bootstrap/theme.info index 8812944..b084985 100644 --- a/examples/roc_api/site/www/themes/bootstrap/theme.info +++ b/examples/roc_api/site/www/themes/bootstrap/theme.info @@ -10,4 +10,5 @@ regions[help] = Help regions[footer] = Footer regions[first_sidebar] = first sidebar regions[second_sidebar] = second sidebar -regions[page_bottom] = Bottom \ No newline at end of file +regions[page_bottom] = Bottom +navigation=default_nav \ No newline at end of file diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl deleted file mode 100644 index c91d22c..0000000 --- a/examples/roc_api/site/www/themes/bootstrap/tpl/menu.tpl +++ /dev/null @@ -1,3 +0,0 @@ - {foreach item="item" from="$menu.items"} -
  • {$item.title/}
  • - {/foreach} diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/page_header2.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/page_header2.tpl index 6eaecd5..5f1e3e6 100644 --- a/examples/roc_api/site/www/themes/bootstrap/tpl/page_header2.tpl +++ b/examples/roc_api/site/www/themes/bootstrap/tpl/page_header2.tpl @@ -1,8 +1,28 @@ - {if isset="$primary_nav"} + {if isset="$default_nav"} + +{/if} \ No newline at end of file diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/primary_nav.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/primary_nav.tpl new file mode 100644 index 0000000..221563a --- /dev/null +++ b/examples/roc_api/site/www/themes/bootstrap/tpl/primary_nav.tpl @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/examples/roc_api/site/www/themes/bootstrap/tpl/secondary_nav.tpl b/examples/roc_api/site/www/themes/bootstrap/tpl/secondary_nav.tpl new file mode 100644 index 0000000..a40739c --- /dev/null +++ b/examples/roc_api/site/www/themes/bootstrap/tpl/secondary_nav.tpl @@ -0,0 +1,7 @@ + + \ No newline at end of file