Do not include empty blocks, this way, we avoid empty sidebars if not needed.
This commit is contained in:
@@ -23,7 +23,12 @@ feature -- Access
|
|||||||
html_options: detachable CMS_HTML_OPTIONS
|
html_options: detachable CMS_HTML_OPTIONS
|
||||||
-- Optional addition html options.
|
-- Optional addition html options.
|
||||||
|
|
||||||
feature -- status report
|
feature -- Status report
|
||||||
|
|
||||||
|
is_empty: BOOLEAN
|
||||||
|
-- Is current block empty?
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
is_enabled: BOOLEAN
|
is_enabled: BOOLEAN
|
||||||
-- Is current block enabled?
|
-- Is current block enabled?
|
||||||
@@ -93,4 +98,7 @@ feature -- Status report
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ feature {NONE} -- Initialization
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
name: READABLE_STRING_8
|
name: READABLE_STRING_8
|
||||||
-- Block region name.
|
-- Block region name.
|
||||||
|
|
||||||
blocks: ARRAYED_LIST [CMS_BLOCK]
|
blocks: ARRAYED_LIST [CMS_BLOCK]
|
||||||
-- List of blocks.
|
-- List of blocks.
|
||||||
|
|
||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
@@ -35,8 +34,15 @@ feature -- Element change
|
|||||||
blocks.force (b)
|
blocks.force (b)
|
||||||
end
|
end
|
||||||
|
|
||||||
;note
|
remove (b: CMS_BLOCK)
|
||||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
require
|
||||||
|
has_block_b: blocks.has (b)
|
||||||
|
do
|
||||||
|
blocks.prune_all (b)
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
source: "[
|
source: "[
|
||||||
Eiffel Software
|
Eiffel Software
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
|
is_empty: BOOLEAN
|
||||||
|
-- Is current block empty?
|
||||||
|
do
|
||||||
|
Result := is_raw and content.is_empty
|
||||||
|
end
|
||||||
|
|
||||||
is_raw: BOOLEAN assign set_is_raw
|
is_raw: BOOLEAN assign set_is_raw
|
||||||
-- Is raw?
|
-- Is raw?
|
||||||
-- If True, do not get wrapped it with block specific div
|
-- If True, do not get wrapped it with block specific div
|
||||||
@@ -87,7 +93,7 @@ feature -- Conversion
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
note
|
note
|
||||||
copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others"
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
source: "[
|
source: "[
|
||||||
Eiffel Software
|
Eiffel Software
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
|
is_empty: BOOLEAN
|
||||||
|
-- Is current block empty?
|
||||||
|
do
|
||||||
|
Result := menu.is_empty
|
||||||
|
end
|
||||||
|
|
||||||
is_horizontal: BOOLEAN assign set_is_horizontal
|
is_horizontal: BOOLEAN assign set_is_horizontal
|
||||||
-- Is horizontal layout for the menu?
|
-- Is horizontal layout for the menu?
|
||||||
|
|
||||||
@@ -72,4 +78,7 @@ feature -- Conversion
|
|||||||
Result := a_theme.menu_html (menu, is_horizontal, html_options)
|
Result := a_theme.menu_html (menu, is_horizontal, html_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
|
is_empty: BOOLEAN = False
|
||||||
|
-- Is current block empty?
|
||||||
|
|
||||||
is_raw: BOOLEAN
|
is_raw: BOOLEAN
|
||||||
-- Is raw?
|
-- Is raw?
|
||||||
-- If True, do not get wrapped it with block specific div
|
-- If True, do not get wrapped it with block specific div
|
||||||
@@ -192,4 +195,7 @@ feature -- Debug
|
|||||||
end
|
end
|
||||||
Result.append ("%N}")
|
Result.append ("%N}")
|
||||||
end
|
end
|
||||||
|
note
|
||||||
|
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -738,7 +738,9 @@ feature -- Generation
|
|||||||
prepare (page: CMS_HTML_PAGE)
|
prepare (page: CMS_HTML_PAGE)
|
||||||
local
|
local
|
||||||
lnk: CMS_LINK
|
lnk: CMS_LINK
|
||||||
|
l_region: CMS_BLOCK_REGION
|
||||||
l_menu_list_prepared: ARRAYED_LIST [CMS_LINK_COMPOSITE]
|
l_menu_list_prepared: ARRAYED_LIST [CMS_LINK_COMPOSITE]
|
||||||
|
l_empty_blocks: detachable ARRAYED_LIST [CMS_BLOCK]
|
||||||
do
|
do
|
||||||
-- Menu
|
-- Menu
|
||||||
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
create {CMS_LOCAL_LINK} lnk.make ("Home", "")
|
||||||
@@ -756,14 +758,29 @@ feature -- Generation
|
|||||||
across
|
across
|
||||||
regions as reg_ic
|
regions as reg_ic
|
||||||
loop
|
loop
|
||||||
|
l_region := reg_ic.item
|
||||||
across
|
across
|
||||||
reg_ic.item.blocks as ic
|
l_region.blocks as ic
|
||||||
loop
|
loop
|
||||||
if attached {CMS_MENU_BLOCK} ic.item as l_menu_block then
|
if attached {CMS_MENU_BLOCK} ic.item as l_menu_block then
|
||||||
l_menu_list_prepared.force (l_menu_block.menu)
|
l_menu_list_prepared.force (l_menu_block.menu)
|
||||||
prepare_links (l_menu_block.menu)
|
prepare_links (l_menu_block.menu)
|
||||||
|
if l_menu_block.menu.is_empty then
|
||||||
|
if l_empty_blocks = Void then
|
||||||
|
create l_empty_blocks.make (1)
|
||||||
|
end
|
||||||
|
l_empty_blocks.force (l_menu_block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if l_empty_blocks /= Void then
|
||||||
|
across
|
||||||
|
l_empty_blocks as ic
|
||||||
|
loop
|
||||||
|
l_region.remove (ic.item)
|
||||||
|
end
|
||||||
|
l_empty_blocks := Void
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prepare menu not in a block.
|
-- Prepare menu not in a block.
|
||||||
|
|||||||
Reference in New Issue
Block a user