Liferay - Error setting preferences of sitemap portlet in Theme - liferay

I am adding a sitemap portlet at the footer of my theme, and when I instance it I set the preferences for the root layout id, display depth and show hidden pages.
My portal-normal.vm snippet:
#* Sitemap for the Footer Links *#
#set ($portlet_id = '85')
#set ($instance_id = 'AAAC')
#* Preferences *#
#set ($rootLayoutId = "f74bd692-715f-4532-8490-dee211bebed8")
#set ($displayDepth = 0)
#set ($showHiddenPages = true)
#set ($myPortletId = "${portlet_id}_INSTANCE_${instance_id}")
$velocityPortletPreferences.setValue('portlet-setup-show-borders', 'false')
$velocityPortletPreferences.setValue('rootLayoutId', 'f74bd692-715f-4532-8490-dee211bebed8')
$velocityPortletPreferences.setValue('displayDepth', '0')
$velocityPortletPreferences.setValue('showHiddenPages', 'false')
$theme.runtime($myPortletId, '', $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())
But the portlet is displayed with the basic preferences.
Haven't found info about preferences names/values, so any help would be appreciated.
Thanks.
EDIT with the solution
Following #Pankaj Kathiriya indication i wrote next code that is correctly working:
#* Sitemap for the Footer Links *#
#set ($portlet_id = '85')
#set ($instance_id = 'AABB')
#* Instanciate the portlet *#
#set ($myPortletId = "${portlet_id}_INSTANCE_${instance_id}")
$velocityPortletPreferences.setValue('portlet-setup-show-borders', 'false')
$velocityPortletPreferences.setValue('rootLayoutUuid', 'f74bd692-715f-4532-8490-dee211bebed8')
$velocityPortletPreferences.setValue('displayDepth', '0')
$velocityPortletPreferences.setValue('showHiddenPages', 'true')
$theme.runtime($myPortletId, '', $velocityPortletPreferences.toString())
#* Reset preferences *#
$velocityPortletPreferences.reset()

Problem is at line below:
$velocityPortletPreferences.setValue('rootLayoutId', 'f74bd692-715f-4532-8490-dee211bebed8')
It should be
$velocityPortletPreferences.setValue('rootLayoutUuid', 'f74bd692-715f-4532-8490-dee211bebed8')
It should be rootLayoutUuid
Regards

Related

TYPO3 menu with typoscript no code generate

I want to create a menu with Typoscript, but it's doesn't work.
I have no code generate. My <body> is empty.
Here my Typoscript code:
# Default PAGE object:
page = PAGE
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/templates/template.html
page.shortcutIcon = fileadmin/templates/favicon.png
page.stylesheet = fileadmin/templates/css/styles.css
page.10.workOnSubpart = DOCUMENT
######################################################
#
# Configuration of SUBPARTS
#
######################################################
# Define the subparts, which are inside the subpart DOCUMENT
page.10.subparts {
##############################################
#
# Subpart NAVMENU
#
##############################################
# The subpart NAVMENU outputs the meta navigation
# at the top right corner of the page
NAVMENU = HMENU
NAVMENU.wrap = <ul>|</ul>
# Only display special pages here: Contact and Imprint
METANAV.special = list
# LIST NEEDS MODIFICATION:
# Take your page IDs!
# Change the values in the following list!
NAVMENU.special.value = 70, 92, 74, 91
NAVMENU.1 = TMENU
NAVMENU.1 {
# NO: default formatting
NO = 0
NO {
# Each entry is wrapped by
# <li> </li>
allWrap = <li>|</li>
}
}
}
######################################################
#
# Configuration of MARKERS
#
######################################################
# Define the markers inside the subpart DOCUMENT
page.10.marks {
}
Here is the tutorial helping me to make my menu: http://wiki.typo3.org/Templating_Tutorial_-_Basics
You have a METANAV in between your NAVMENU configuration:
NAVMENU = HMENU
NAVMENU.wrap = <ul>|</ul>
# Only display special pages here: Contact and Imprint
METANAV.special = list
Change the last line to NAVMENU as well or use curly braces. Make sure in your Template html file a DOCUMENT subpart exsts and inside that subpart a NAVMENU subpart exists. Only then you will see output.
The answer form Daniel is right.
And there are different states of a menu. NO is the default state and you do not need to deactivate it (it's wrong: NO = 0). Only if you need more states you have to set each one like ACT = 1 (CUR = 1 and so on).
NAVMENU= HMENU
NAVMENU {
special = list
special.value = 70, 92, 74, 91
1 = TMENU
1.wrap = <ul>|</ul>
1{
NO{
wrapItemAndSub = <li class="menu-normal">|</li>
}
ACT=1
ACT{
wrapItemAndSub = <li class="menu-active">|</li>
}
}
}

how to set asset publisher tag with hard coded

I added an asset publisher to liferay and add it to "portal-normal.vm" with "Portlet Id".
But this portlet (added with portlet Id to my theme) Does not inherit that portlet settings.
Now I want to set asset publisher tag with hard code, but I don't know how do it.
#set ($VOID = $velocityPortletPreferences.setValue('display-style', '1'))
#set ($VOID = $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false"))
#set ($instanceId = '6nro')
#set ($myPortletId = "101_INSTANCE_${instanceId}")
#set ($portletSetup = $portletPreferencesFactoryUtil.getLayoutPortletSetup($layout, $myPortletId))
$theme.runtime($myPortletId, $queryString, $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()

Add the Author Profile Picture on WebContent

I have a Liferay WebContent that is based on a Structure and Template. I want to display the Author picture (from Liferay UserProfile) as part of the Template.
Is there a way to access that Information with Velocity?
I found this variable:
$reserved-article-author-id
However, is there an easy way to get the Picture using the AuthorID?
In the profile page, pictures are displayed this way:
The imgid is not the same as the userid. Is there an easy way to get the imgid from the userid?
Liferay Version is 6.1.
This should work on 6.1:
#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($user = $userLocalService.fetchUserById($getterUtil.getLong($reserved-article-author-id.data)))
#set ($profilePicUrl = $request.theme-display.path-image + "/user_")
#if ($user.isFemale())
#set ($profilePicUrl = $profilePicUrl + "female")
#else
#set ($profilePicUrl = $profilePicUrl + "male")
#end
#set ($profilePicUrl = $profilePicUrl + "_portrait?img_id=")
#set ($profilePicUrl = $profilePicUrl + $user.getPortraitId())
<img src="$profilePicUrl" />
Note that you must have journal.template.velocity.restricted.variables= in your portal-ext.properties file, to allow access to $serviceLocator
thanks for the answer, helped me out!
just a little thing
#set ($profilePicUrl = $request.theme-display.path-image + "/user_")
didnt work for me in liferay 6.2 GA2, it seems $request.theme-display.path-image doesnt work in the new version
but i solved like this:
#set ($profilePicUrl = "$theme_display.getPathImage()" + "/user_")
hope it helps someone :)
This work on 6.2:
Try this:
#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($jaId = $getterUtil.getString($reserved-article-id.data))
#set ($ja = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$jaId))
#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($usuario = $userLocalService.getUserById($getterUtil.getLong($ja.getUserId())))
#set ($tD = $request.get("theme-display")) #set ($DigesterUtil = $portal.getClass().forName("com.liferay.portal.kernel.util.DigesterUtil"))
#set ($DigesterUtil = $portal.getClass().forName("com.liferay.portal.kernel.util.DigesterUtil"))
#set ($profilePicUrl = $profilePicUrl + "_portrait?img_id=")
#set ($profilePicUrl = $profilePicUrl + $usuario.getPortraitId())
#set ($profilePicUrl = $tD.get("path-image") + "/user_")
#if ($usuario.isFemale())
#set ($profilePicUrl = $profilePicUrl + "female")
#else
#set ($profilePicUrl = $profilePicUrl + "male")
#end
#set ($profilePicUrl = $profilePicUrl + "_portrait?img_id=")
#set ($profilePicUrl = $profilePicUrl + $usuario.getPortraitId())
#set ($profilePicUrl = $profilePicUrl + "&img_id_token=")
#set ($profilePicUrl = $profilePicUrl + $httpUtil.encodeURL($DigesterUtil.digest($usuario.getUuid())))
<div class="img_user">
<img src="$profilePicUrl"/>
</div>
Here is smaller version for Liferay 6.2:
#set($userConstants = $portal.getClass().forName("com.liferay.portal.model.UserConstants"))
#set($portraitUrl = $userConstants.getPortraitURL($request.theme-display.path-image, $user.male, $user.portraitId, $user.userUuid))
Regards,
Martin

Liferay, how to initiate the certain web content in Velocity

I've been playing around of this issue for awhile now and can't get my head wrapped around of it. I'm using Liferay 6.1 CE GA2.
Goal:
User editable content, for example footer in each page. I've created the web content which id is 12701.
Method:
#set ($local_temp_content = $journalContentUtil.getContent($scope_group_id, "12701", null, "$locale", $theme_display))
$local_temp_content<br />
Issue:
It won't return anything sensible. It's just printing "$local_temp_content" as the result.
Any pointers how to debug this issue?
This is a velocity macro to retrieve a web content by ID from local scope first and then by global scope:
#macro(glarticle $temp_article_id)
#set ($temp_content = "")
#set ($scope_group_id = $theme_display.scopeGroupId)
#set ($global_group_id = $theme_display.companyGroupId)
#set ($temp_content = $journalContentUtil.getContent($scope_group_id, $temp_article_id, null, "$locale", $theme_display))
#set ($temp_content = "$!{temp_content}")
#if ($temp_content.length() == 0)
#set ($temp_content = $journalContentUtil.getContent($global_group_id, $temp_article_id, null, "$locale", $theme_display))
#end
$!{temp_content}
#end
How to use it:
#glarticle('1234')
For debugging velocity try outputting every part of your call.
scope_group_id = $scope_group_id<br>
theme_display = $theme_display<br>
journalContentUtil = $journalContentUtil<br>
If you get exactly what you wrote than that variable is not available.
If all are resolved then possibilitis are:
wrong article id
there was exception during article rendering (you should check log)

How to get image using structure and template to get title,small and large image

I am using liferay 6.1.20.
Structure variable demo_image : type Document and Media
here is my template code. It is not fetching uuid or groupId from url !
#set ($dlLocalService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppLocalService"))
#set ($url = $getterUtil.getString($demo_image.getData()))
#set ($uuid = $getterUtil.getString($httpUtil.getParameter($url, "uuid", false)))
#set ($groupId = $getterUtil.getLong($httpUtil.getParameter($url, "groupId", false)))
#set ($imageObj = $dlLocalService.getFileEntryByUuidAndGroupId($uuid,$groupId))
#set ($imageSmallid = $imageObj.getSmallImageId())
#set ($imageLargeid = $imageObj.getLargeImageId())
#set ($imageTitle = $imageObj.getTitle())
#set ($imageDescription = $imageObj.getDescription())
#set ($urlLargeImage = "/documents/imageLargeid")
#set ($urlSmallImage = "/documents/imageSmallid")
$imageTitle
<img src="$urlSmallImage" rel="$imageTitle" alt="$imageTitle" />
Check value of $url for your image, does this URL contain uuid & groupId if yes you should get the values. else if url contains imageId try using different method from service util.
Also try using DLFileE‌​ntryLocalService instead of DLAppLocalService
Hope this helps you find your solution !

Resources