Update theme information defining a navigation strategy
Updated code to use a new navigation strategy.
This commit is contained in:
@@ -20,9 +20,9 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
to_implement ("Refactor, take the info from a Database or Configuration file.")
|
to_implement ("Refactor, take the info from a Database or Configuration file.")
|
||||||
create items.make (5)
|
create items.make (5)
|
||||||
force (create {CMS_MENU}.make ("main-menu", 3)) -- primary menu
|
force (create {CMS_MENU}.make ("primary_nav", 3)) -- primary menu
|
||||||
force (create {CMS_MENU}.make_with_title ("management", "Management", 3)) -- secondary in admin view.
|
force (create {CMS_MENU}.make_with_title ("management_nav", "Management", 3)) -- secondary in admin view.
|
||||||
force (create {CMS_MENU}.make_with_title ("navigation", "Navigation", 3)) -- secondary
|
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
|
force (create {CMS_MENU}.make_with_title ("user", "User", 3)) -- first_side_bar
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -42,17 +42,17 @@ feature -- Access
|
|||||||
|
|
||||||
main_menu: CMS_MENU
|
main_menu: CMS_MENU
|
||||||
do
|
do
|
||||||
Result := item ("main-menu")
|
Result := item ("primary_nav")
|
||||||
end
|
end
|
||||||
|
|
||||||
management_menu: CMS_MENU
|
management_menu: CMS_MENU
|
||||||
do
|
do
|
||||||
Result := item ("management")
|
Result := item ("management_nav")
|
||||||
end
|
end
|
||||||
|
|
||||||
navigation_menu: CMS_MENU
|
navigation_menu: CMS_MENU
|
||||||
do
|
do
|
||||||
Result := item ("navigation")
|
Result := item ("secondary_nav")
|
||||||
end
|
end
|
||||||
|
|
||||||
user_menu: CMS_MENU
|
user_menu: CMS_MENU
|
||||||
|
|||||||
@@ -217,10 +217,10 @@ feature -- Blocks
|
|||||||
set_header_block (a_page: CMS_HTML_PAGE)
|
set_header_block (a_page: CMS_HTML_PAGE)
|
||||||
do
|
do
|
||||||
if not main_menu.is_empty then
|
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
|
end
|
||||||
if not navigation_menu.is_empty then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -314,31 +314,6 @@ feature -- Blocks
|
|||||||
do
|
do
|
||||||
create s.make_from_string (theme.menu_html (main_menu, True))
|
create s.make_from_string (theme.menu_html (main_menu, True))
|
||||||
create l_hb.make_empty
|
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 := "[
|
|
||||||
<div class='navbar navbar-inverse'>
|
|
||||||
<div class='navbar-inner nav-collapse' style='height: auto;'>
|
|
||||||
<ul class='nav'>
|
|
||||||
]"
|
|
||||||
l_hb.append (s)
|
|
||||||
l_hb.append ("[
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
]")
|
|
||||||
|
|
||||||
end
|
|
||||||
create Result.make ("header", Void, l_hb, formats.full_html)
|
create Result.make ("header", Void, l_hb, formats.full_html)
|
||||||
Result.set_is_raw (True)
|
Result.set_is_raw (True)
|
||||||
end
|
end
|
||||||
@@ -639,6 +614,9 @@ feature -- Generation
|
|||||||
call_menu_alter_hooks (menu_system)
|
call_menu_alter_hooks (menu_system)
|
||||||
prepare_menu_system (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)
|
set_blocks (page)
|
||||||
-- get_blocks
|
-- get_blocks
|
||||||
-- across
|
-- across
|
||||||
@@ -659,16 +637,16 @@ feature -- Generation
|
|||||||
page.set_title ("CMS::" + request.path_info)
|
page.set_title ("CMS::" + request.path_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- -- blocks
|
-- blocks
|
||||||
-- across
|
across
|
||||||
-- regions as reg_ic
|
regions as reg_ic
|
||||||
-- loop
|
loop
|
||||||
-- across
|
across
|
||||||
-- reg_ic.item.blocks as ic
|
reg_ic.item.blocks as ic
|
||||||
-- loop
|
loop
|
||||||
-- page.add_to_region (theme.block_html (ic.item), reg_ic.item.name)
|
page.add_to_region (theme.block_html (ic.item), reg_ic.item.name)
|
||||||
-- end
|
end
|
||||||
-- end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
common_prepare (page: CMS_HTML_PAGE)
|
common_prepare (page: CMS_HTML_PAGE)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ feature -- Execution
|
|||||||
process
|
process
|
||||||
-- Computed response message.
|
-- Computed response message.
|
||||||
do
|
do
|
||||||
set_title ("Home")
|
set_title (Void)
|
||||||
set_page_title (Void)
|
set_page_title (Void)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
navigation_template: detachable READABLE_STRING_GENERAL
|
||||||
|
-- navigation template name, if any.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
feature -- Conversion
|
feature -- Conversion
|
||||||
|
|
||||||
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ feature -- Conversion
|
|||||||
Result := html_template.to_html (page)
|
Result := html_template.to_html (page)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
navigation_template: detachable READABLE_STRING_GENERAL
|
||||||
|
-- navigation template name, if any.
|
||||||
|
do
|
||||||
|
end
|
||||||
|
|
||||||
feature {NONE} -- Internal
|
feature {NONE} -- Internal
|
||||||
|
|
||||||
internal_page_template: detachable like page_template
|
internal_page_template: detachable like page_template
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ feature -- Access
|
|||||||
Result := tpl
|
Result := tpl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
navigation_template: detachable READABLE_STRING_GENERAL
|
||||||
|
-- navigation template name, if any.
|
||||||
|
do
|
||||||
|
Result := information.item ("navigation")
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Conversion
|
feature -- Conversion
|
||||||
|
|
||||||
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
menu_html (a_menu: CMS_MENU; is_horizontal: BOOLEAN): STRING_8
|
||||||
@@ -83,13 +89,7 @@ feature -- Conversion
|
|||||||
tpl: SMARTY_CMS_PAGE_TEMPLATE
|
tpl: SMARTY_CMS_PAGE_TEMPLATE
|
||||||
l_page: CMS_HTML_PAGE
|
l_page: CMS_HTML_PAGE
|
||||||
do
|
do
|
||||||
to_implement ("Proof of concept to load a Menu from a tpl/menu.tpl.")
|
create tpl.make ("tpl/" + a_menu.name, Current)
|
||||||
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 l_page.make
|
create l_page.make
|
||||||
l_page.register_variable (a_menu, "menu")
|
l_page.register_variable (a_menu, "menu")
|
||||||
tpl.prepare (l_page)
|
tpl.prepare (l_page)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<!-- Page Header -->
|
<!-- Page Header -->
|
||||||
<div id="header">
|
<div id="header">
|
||||||
{include file="tpl/page_header.tpl"/}
|
{include file="tpl/page_header2.tpl"/}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- General Page Content -->
|
<!-- General Page Content -->
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ regions[help] = Help
|
|||||||
regions[footer] = Footer
|
regions[footer] = Footer
|
||||||
regions[first_sidebar] = first sidebar
|
regions[first_sidebar] = first sidebar
|
||||||
regions[second_sidebar] = second sidebar
|
regions[second_sidebar] = second sidebar
|
||||||
regions[page_bottom] = Bottom
|
regions[page_bottom] = Bottom
|
||||||
|
navigation=default_nav
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{foreach item="item" from="$menu.items"}
|
|
||||||
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
|
||||||
{/foreach}
|
|
||||||
@@ -1,8 +1,28 @@
|
|||||||
{if isset="$primary_nav"}
|
{if isset="$default_nav"}
|
||||||
|
<div class="navbar navbar-default" role="navigation">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||||
|
<span class="sr-only">Toggle navigation</span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="${site_url/}" itemprop="home" rel="home">{$page_title/}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="navbar-collapse collapse">
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{if isset="$primary_nav"}
|
||||||
{$primary_nav/}
|
{$primary_nav/}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{if isset="$secondary_nav"}
|
{if isset="$secondary_nav"}
|
||||||
{$secondary_nav/}
|
{$secondary_nav/}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{if isset="$default_nav"}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<ul class="nav navbar-nav navbar-left">
|
||||||
|
{foreach item="item" from="$menu.items"}
|
||||||
|
<!-- TODO check if a menu item is active or not -->
|
||||||
|
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
{foreach item="item" from="$menu.items"}
|
||||||
|
<!-- TODO check if a menu item is active or not -->
|
||||||
|
<li class="active"><a href="{$item.location/}">{$item.title/}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
|
||||||
Reference in New Issue
Block a user