Forum Discussion

Shivshankar's avatar
7 years ago

This widget could not be displayed.

I have a piece of code in custom widget.

<#if !user.anonymous>
    <#assign userLanguage=restadmin("/users/id/${user.id?c}/profiles/name/language").value />
    <#assign loginStatus="Yes">
    <#assign userRank=restadmin('users/id/${user.id?c}/ranking').ranking.name />
    <#assign userRolesRequest=restadmin('users/id/${user.id?c}/roles') />
    <#if userRolesRequest.roles?? && userRolesRequest.roles?has_content>
        <#list userRolesRequest.roles.role as r>
            <#assign userRole+= r.name+":"/>
        </#list>
        <#assign userRole=userRole?substring(0,userRole?length-1)/>
    </#if>
</#if>

When user is not logged in(anonymous) or admin this is not giving any issue.

But for Non admin users this is showing "widget could not be displayed".

I have put down all condition checks still error is there , what might be the reason and i am unable to figure out where if i am missing something.

Please suggest.

  • Shivshankar - One of the issues is on the line number 8. 

     


    wrote:
    <#assign userRole+= r.name+":"/>

     


    Freemarker doesn't support concatenating variable like JS. (userRole+=

     

    Please update 8th line as below. 

    <#assign userRole= userRole + r.name+":"/>

     

4 Replies

  • Shivshankar - One of the issues is on the line number 8. 

     


    wrote:
    <#assign userRole+= r.name+":"/>

     


    Freemarker doesn't support concatenating variable like JS. (userRole+=

     

    Please update 8th line as below. 

    <#assign userRole= userRole + r.name+":"/>

     

  • Shivshankar's avatar
    Shivshankar
    Ace
    7 years ago

    Wow corrected it and it solved issue. Thanks a lot. Though it was weird observing it for only non-admin and logged in.

  • TariqHussain's avatar
    TariqHussain
    Boss
    7 years ago

    Shivshankar- Lithium doesn't allow the normal user to see the error. A user has to be the admin in order to see what the issue. All normal users or log out users will only see widget could not be displayed.