質問

I followed this guide to create a Custom field in Liferay. I have created a true/false attribute, but i want to check if this attribute is true or false, if is true get to the menu/Page a cssClass. I tried with this:

#set ($menu = $nav_item.getLayout().getExpandoBridge().getAttribute("get-menu"))
#if ($menu == "true")
    <a href="" class="menu True">$nav_child.getName()</a>
#else
    <a href="" class="menu">$nav_child.getName()</a>
#end

But doesn't work!
How can i check if Custom Attribute has value true or false?
Any help is greatly appreciated! Thank you so much!

役に立ちましたか?

解決

If get-menu custom field for Page is declared as boolean above if condition should work

#if ($menu)
#if ($menu == true)

If it still does not work Check Database for ExpandoColumn table it will have your column name get-menu and default value if set.

ExpandoValue table will have actual value for your custom field, look for columnId that correspond your custom field and classPK which will be your page layout ID. This row will have your Value i.e. Either true / False.

If this row is present for your Page it should work in your VM code above.

Hope this helps you !

他のヒント

If that is a boolean value, you can use any of:

#if ($menu)
#if ($menu == true)
#if ("$!menu" == 'true')

However, it should work with your code as well, so maybe you're reading the value wrong. What is the value of $menu? Just print it to find out.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top