Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Srividhya Mohanasundaram
Web Content Template in portal_normal.vm
January 11, 2013 11:41 AM
Answer

Srividhya Mohanasundaram

Rank: New Member

Posts: 20

Join Date: June 29, 2012

Recent Posts

Hi

I want to include web content which has a structure and template in portal_normal.vm file. I have attached my web content and structure files. And here is my template. If you look at the template none of the variables $request.get("attributes").USER_ID are getting resolved. It works fine if I select this web content through web content display portlet

#set($userId = $request.get("attributes").USER_ID)
#set($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set($user = $userLocalService.getUserById($getterUtil.getLong($userId)))

<div id="header-con">
<div id="user">
<div id="user-fullname">
#if ( $user.getFirstName() )
$user.getFirstName()
#end
#if ( $user.getLastName() )
$user.getLastName(),
#end
</div>
</div>
</div>


Here is my portal_normal.vm

<!DOCTYPE html>

#parse ($init)

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

<head>
<title>$the_title - $company_name </title>
$theme.include($top_head_include)
</head>

<body class="$css_class">

$theme.include($body_top_include)

#if ($is_signed_in)
#dockbar()
#end

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

<header id="banner" role="banner">

<div id="$header_class">
#set ($header-content-id = "109606")
#set ($header-template-id = "109603")
#set($header-content=$journalContentUtil.getContent($group_id, $header-content-id,$header-template-id,"$locale",$themeDisplay))
$header-content
</div>
</header>

<div id="content">

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

$portletDisplay.setTitle($the_title)

$theme.wrapPortlet("portlet.vm", $content_include)
#end

</div>
</div>

$theme.include($body_bottom_include)

</body>

$theme.include($bottom_include)

</html>
Attachment

Attachment

Attachments: Screen Shot 2013-01-11 at 2.15.59 PM.png (58.6k), Screen Shot 2013-01-11 at 2.16.16 PM.png (56.8k)
Parikshit Sharma
RE: Web Content Template in portal_normal.vm
January 17, 2013 4:50 AM
Answer

Parikshit Sharma

Rank: New Member

Posts: 21

Join Date: January 16, 2013

Recent Posts

Hi,
$journalContentUtil.getContent(groupId,articleId, templateId, viewMode, languageId, themeDisplay) it won't work until you create the object of themeDisplay in velocity.What we is( key- value) pair not the object of themeDisplay class,so check the ThemeDisplay class and set the required values same as we do in Java and you will get the required Object of theme and then above method will worked out.