These are the different ways and places you can use to hide content.
Example1:
For example, say you would like to add an article that shows a download button for a document available to registered users only. One approach would be to use a web content structure and template duo and add the logic to hide the button on the web content structure.
Web Content Structure:
#if ($request.remote-user)
<div id="downloadResource" class="downloadResource">
<a id="documentDownload" href="$URL.getData()" onclick="addLead('$Title.getData()', '$URL.getData()', $jq(this));">
<img src="/shp-theme/images/download.jpg" />
</a>
</div>
#end
Example 2:
Another example, would be to show certain plugins on a page only to registered users. In this case a Layout template with an embedded portlet and hiding logic is useful.
Layout Plugin - Velocity Template:
#if($user.isDefaultUser() || $permissionChecker.isCompanyAdmin())Example 3:
<!-- Place code for embedded portlet here -->
$theme.runtime("userregistration_WAR_userreg_")
#end
This is probably the most useful example for a lot of developers. Using mobile device rules, we can change layouts and themes for mobile devices. You can either embedded portlets on the regular layout and remove them for the mobile theme or layout. Another approach is to prevent the portlets (image marquee, etc) from rendering on page when a mobile device is used.
Hide Portlets from Mobile Devices:
We don't touch Liferay ext or source code, instead we used a hook for render_portlet.jsp:
First determine if request is made from a mobile device:
if (BrowserSnifferUtil.isMobile(request)) {Then we added the showPortletForMobile boolean to the condition:
MobileRenderingConfig mobileRenderingConfig = MobileRenderingConfigLocalServiceUtil.findByLayoutId(previousScopeGroupId,layout.getLayoutId());
String portletIds = mobileRenderingConfig.getPortletIds();
showPortletForMobile = !portletIds.contains(portletId);
}
if (portlet.isActive() && portlet.isReady() && access && supportsMimeType && showPortletForMobile && (invokerPortlet != null)) {
}
...
No comments:
Post a Comment