Forum Discussion

Wendy_S's avatar
11 years ago

remove IF Statement from custom component

I logged the ticket below as a support ticket but actually thought I might share here as well since I believe you folks may be able to help, give inputs (and maybe you are part of the same support te...
  • VarunGrazitti's avatar
    VarunGrazitti
    11 years ago

    As HaidongG  mentioned, you could use macros and functions as well, but as this is not too bigger a code, you could just remove the If conditions, and it'd work just fine. After stripping off the code in red and putting the line in green inside the if block;

     

    <#assign user_has_role = false /> 
    <#if user.registered > 
         <#list restadmin("/users/id/${user.id?c}/roles").roles.role as role> 
            <#if role.name?? && (role.name == "PHD" || role.name == "Ambassador" || role.name == "Administrator")> 
                 <#assign user_has_role = true /> 
            </#if> 
           </#list> 
    </#if> 
    <#if user_has_role > 
    <p><a href="http://h30434.www3.hp.com/t5/forums/searchpage/tab/message?sort_by=-topicPostDate&amp;advanced=true&..." target="_self">Unanswered Posts</a></p> 
    </#if> 

     

    you'll be left with below.

     

    <#if user.registered > 
            <p><a href="http://h30434.www3.hp.com/t5/forums/searchpage/tab/message?sort_by=-topicPostDate&amp;advanced=true&..." target="_self">Unanswered Posts</a></p> 
    </#if> 

     

  • VarunGrazitti's avatar
    VarunGrazitti
    11 years ago

    Wendy_S  here you go :)

     

    <#if user.registered > 
    	<div class="lia-panel lia-panel-standard unanswered-posts"> 
           <div class="lia-decoration-border"> 
            <div class="lia-decoration-border-top"> 
         <div> </div> 
           </div> 
           <div class="lia-decoration-border-content"> 
      <div> 
    <div class="lia-panel-heading-bar-wrapper"> 
    <div class="lia-panel-heading-bar"> 
    <span class="lia-panel-heading-bar-title">${text.format("unanswered-posts.head.title")}</span> 
    </div> 
    </div> 
    <div class="lia-panel-content-wrapper"> 
    <div class="lia-panel-content"> 
    <div class="lia-button-group"> 
    <span class="lia-button-wrapper lia-button-wrapper-secondary lia-component-forums-action-escalate-message-button"> 
    <div class="lia-button lia-button-secondary escalate-message"> 
    <a href="/t5/forums/searchpage/tab/message?sort_by=-topicPostDate&amp;advanced=true&amp;search_type=thread&amp;search_page_size=10&amp;openresponse=true&amp;filter=openResponse" target="_self">${text.format("unanswered-posts.button.title")}</a> 
    </div> 
    </span> 
    </div> 
    
    </div> 
    </div> 
    </div> 
    </div> 
    <div class="lia-decoration-border-bottom"> 
    <div> </div> 
    </div> 
    </div> 
    </div> 
    </#if>