0

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?

Heikki Mustonen
  • 301
  • 3
  • 15

2 Answers2

1

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')
Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21
  • This seems to work nicely and bringing the content. I'm trying to make it a bit more usable for user thus I used Tejas Kanami's snippet from: http://www.opensourceforlife.com/2013/05/embed-selected-web-content-in-liferay.html#comment-form. I still have an issue with this. I can't initiate multiple instances on the same page, since it's rendering the same content on each portlet. I've tried different instance IDs but it doesn't seem to affect on the business. – Heikki Mustonen Jan 02 '14 at 10:50
0

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)
Martin Gamulin
  • 3,855
  • 21
  • 25