Permalink
Browse files

core: optional: install default menu from site config.

When using the empty skeleton, look for a default menu in the site config:

[
        ...
        {skeleton, empty},
        {default_menu, [{menu_item1, []}, {menu_item2, [{submenu_item, []}]}]},
        ...
].
  • Loading branch information...
kaos committed Nov 15, 2012
1 parent 03136c2 commit 24898c92242f7902a39906cffc6e5b921f56ea79
Showing with 12 additions and 4 deletions.
  1. +1 −1 modules/mod_menu/mod_menu.erl
  2. +11 −3 src/install/z_install_defaultdata.erl
@@ -381,7 +381,7 @@ manage_schema(install, Context) ->
{main_menu,
menu,
[{title, <<"Main menu">>},
- {menu, case z_install_defaultdata:default_menu(m_site:get(skeleton, Context)) of
+ {menu, case z_install_defaultdata:default_menu(Context) of
undefined -> [];
Menu -> Menu
end}
@@ -146,11 +146,19 @@ install(_, _) ->
ok.
-%% @doc Retrieve the default menu structure for a given skeleton site. Used by mod_menu to create the menu.
-default_menu(blog) ->
+%% @doc Retrieve the default menu structure for a given site. Used by mod_menu to create the menu.
+default_menu(Context) ->
+ case m_site:get(skeleton, Context) of
+ empty ->
+ m_site:get(default_menu, Context);
+ Skeleton ->
+ default_skeleton_menu(Skeleton)
+ end.
+
+default_skeleton_menu(blog) ->
[{page_home, []}, {page_about, []}, {page_contact, []}];
-default_menu(_) ->
+default_skeleton_menu(_) ->
%% no/unknown skeleton = no default menu
undefined.

3 comments on commit 24898c9

@arjan

This comment has been minimized.

Show comment Hide comment
@arjan

arjan Nov 16, 2012

Member

Nice; but why is this only for the "empty" skeleton?

Member

arjan replied Nov 16, 2012

Nice; but why is this only for the "empty" skeleton?

@kaos

This comment has been minimized.

Show comment Hide comment
@kaos

kaos Nov 16, 2012

Member

The blog skeleton already has a default menu... other skeletons are yet undefined. But feel free to adapt it further ;)

Member

kaos replied Nov 16, 2012

The blog skeleton already has a default menu... other skeletons are yet undefined. But feel free to adapt it further ;)

@kaos

This comment has been minimized.

Show comment Hide comment
@kaos

kaos Nov 16, 2012

Member

Aha... maybe move out the default blog skeleton menu to the skeleton config, that way it would get generic regardless of skeleton.

And on the same note, perhaps do that with the modules to install too (the other commit I pushed last night)... as I'm currently pondering on a way to uninstall some of the default installed modules (if I want to replace the acl module, for instance).

Member

kaos replied Nov 16, 2012

Aha... maybe move out the default blog skeleton menu to the skeleton config, that way it would get generic regardless of skeleton.

And on the same note, perhaps do that with the modules to install too (the other commit I pushed last night)... as I'm currently pondering on a way to uninstall some of the default installed modules (if I want to replace the acl module, for instance).

Please sign in to comment.