使用liferay主题设置的多个导航菜单

时间:2015-06-23 07:42:42

标签: liferay liferay-6 velocity liferay-theme liferay-aui

我正在使用主题设置为主题创建一个带有多个导航菜单的主题,在liferay look-and-feel.xml中我添加了以下代码:

<settings>
    <setting configurable="true" key="navigation" type="select" 
options="left-vertical,right-vertical,horizontal" value="horizontal" />
    </settings>

portal_normal.vm文件:

<!DOCTYPE html>

#parse ($init)

<html class="$root_css_class" dir="#language ("lang.dir")" lang="$w3c_language_id">

<head>
    <title>$the_title - $company_name</title>

    <meta content="initial-scale=1.0, width=device-width" name="viewport" />

    $theme.include($top_head_include)
</head>

## navigation menu selection related code

    #set ($navigationLeft = $theme.getSetting("navigation"))

    #if ($navigationLeft == "left")
        #set ($css_class = "${css_class} navigation-left")
    #end

    #if ($navigationLeft == "left-right")
        #set ($pull1 = "")
        #set ($pull2 = "pull-right")
    #else
        #set ($pull1 = "pull-right")
        #set ($pull2 = "")
    #end



<body class="$css_class">

<a href="#main-content" id="skip-to-content">#language ("skip-to-content")</a>

$theme.include($body_top_include)


    #dockbar()

## docbar settings 

#set ($dockbar = $theme.getSetting("dockbar-mode"))

#if ($dockbar == "split")
    #set ($css_class = "${css_class} dockbar-split")
#end

#set ($navigationLeft = $theme.getSetting("logo-menu-direction"))

#if ($navigationLeft == "left-right")
    #set ($pull1 = "")
    #set ($pull2 = "pull-right")
#else
    #set ($pull1 = "pull-right")
    #set ($pull2 = "")
#end


<div class="container-fluid" id="wrapper">
    <header id="banner" role="banner">
        <div id="heading">
            <h1 class="site-title">
                <a class="$logo_css_class" href="$site_default_url" title="#language_format ("go-to-x", [$site_name])">
                    <img alt="$logo_description" height="$site_logo_height" src="$site_logo" width="$site_logo_width" />

                #*  #if ($show_site_name)
                        <span class="site-name" title="#language_format ("go-to-x", [$site_name])">
                            $site_name
                        </span>
                    #end
                *#
                </a>

            </h1>
            <div class="navigation-menu $pull2">
                <div class="line1"></div>
                <div class="line2"></div>
                <div class="line3"></div>
            </div>


            <h2 class="page-title">
                <span>$the_title</span>
            </h2>

        </div>

        #if ($has_navigation || $is_signed_in)
            #parse ("$full_templates_path/navigation.vm")
        #end
    </header>

    <div id="content">
        <nav id="breadcrumbs">#breadcrumbs()</nav>

        #if ($selectable)
            $theme.include($content_include)
        #else
            $portletDisplay.recycle()

            $portletDisplay.setTitle($the_title)

            $theme.wrapPortlet("portlet.vm", $content_include)
        #end
    </div>

    <footer id="footer" role="contentinfo">
        <p class="powered-by">
            #language ("powered-by") <a href="http://www.liferay.com" rel="external">Liferay</a>
        </p>
    </footer>
</div>

$theme.include($body_bottom_include)

$theme.include($bottom_include)

</body>

</html>

默认情况下,我显示水平菜单。

现在,当用户选择左垂直或右垂直时,我正确显示导航菜单,但每当用户选择水平时,我需要显示默认的水平导航菜单。我该如何实现这一目标?

在上面的代码中,我没有编写任何关于&#39; horizo​​ntal&#39; 的代码,因为我还需要为它编写CSS。而不是当我第一次应用主题时,它将显示水平菜单,当我选择水平时,我需要应用这些设置。

我如何实现它?

1 个答案:

答案 0 :(得分:2)

使用GetterUtil,如果select没有选择值,则可以使用默认值。

这是一个例子:

#set ($navigation = $getterUtil.getString($theme.getSetting("navigation"),"horizontal"))