Added notion of block options, declared in cms.ini as

[blocks]
    {block_id}.options[name]=value
    {block_id}.options[size]=123
This commit is contained in:
2015-10-16 23:11:44 +02:00
parent e90f82387f
commit d2d86ecdf2
2 changed files with 19 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ feature -- Hook
b: CMS_CONTENT_BLOCK
s, l_content: STRING
gen: FEED_TO_XHTML_VISITOR
nb: NATURAL_32
do
if a_block_id.same_string_general ("recent_changes") then
create l_content.make (1024)
@@ -81,7 +82,16 @@ feature -- Hook
s.append_string ("</li>")
gen.set_footer (s)
recent_changes_feed (a_response, 10, Void).accept (gen)
nb := 10
if
attached a_response.block_options (a_block_id) as l_options and then
attached {READABLE_STRING_GENERAL} l_options.item ("size") as l_size and then
l_size.is_integer
then
nb := l_size.to_natural_32
end
recent_changes_feed (a_response, nb, Void).accept (gen)
create b.make (a_block_id, Void, l_content, Void)
a_response.put_block (b, Void, False)

View File

@@ -465,6 +465,14 @@ feature -- Block management
end
end
block_options (a_block_id: READABLE_STRING_8): detachable STRING_TABLE [READABLE_STRING_32]
-- Options associated with `a_block_id' in configuration, if any.
do
if attached setup.text_table_item ("blocks." + a_block_id + ".options") as tb then
Result := tb
end
end
is_block_included (a_block_id: READABLE_STRING_8; dft: BOOLEAN): BOOLEAN
-- Is block `a_block_id' included in current response?
-- If no preference, return `dft'.