I want to add a condition in HTML section under widget

Community Alums
Not applicable

I am using a custom widget in which on the HTML part, I am having a code section for a button-- "Get Support"
----------------------------------------------------------------------
<li class="gt-menu-item">
<button class="btn-supportOne" onclick="window.location.href='?id=one_assist_clone'" role="menuitem" aria-label="Redirect Button">
Get Support
</button>
</li>
---------------------------------------------------------------------
Now, mine requirement is that I do not want this button to be visible on the employee center homepage.

What, where I need to make changes so that I can achieve this functionality.

Thanks & Regards
Utsav

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron

Hi @Utsav JAISWAL ,

 

you need to fetch url prefix of the portal then add the condition.

example 

in widget html :

 

<li class="gt-menu-item">
  <button class="btn-supportOne" 
          onclick="window.location.href='?id=one_assist_clone'" 
          role="menuitem" 
          aria-label="Redirect Button" 
          ng-if="data.portalid !== 'esc'">
    Get Support
  </button>
</li>

 

 

in server script:

 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
  var portalid=$sp.getValue('url_suffix');
data.portalid = portalid;

})();

 

 

 

then it will hide for ESC then it will be there for other portal if they use this widget in other.

 

Please mark helpful & correct answer if it's really worthy for you.

 Thanks,

BK

View solution in original post

2 REPLIES 2

Bhavya11
Kilo Patron

Hi @Utsav JAISWAL ,

 

you need to fetch url prefix of the portal then add the condition.

example 

in widget html :

 

<li class="gt-menu-item">
  <button class="btn-supportOne" 
          onclick="window.location.href='?id=one_assist_clone'" 
          role="menuitem" 
          aria-label="Redirect Button" 
          ng-if="data.portalid !== 'esc'">
    Get Support
  </button>
</li>

 

 

in server script:

 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
  var portalid=$sp.getValue('url_suffix');
data.portalid = portalid;

})();

 

 

 

then it will hide for ESC then it will be there for other portal if they use this widget in other.

 

Please mark helpful & correct answer if it's really worthy for you.

 Thanks,

BK

Community Alums
Not applicable

Hi @Bhavya11 Thankyou very much for the support, it is working as expected..
Just one update ---suppose if I want that the button should only not visible to employee center home page, and else where it should be there...

Example:- Suppose I want to make this visible for below page. And hidden on the esc homepage

UTSAVJAISWAL_0-1729837467132.png

 


Thanks in Advance
Utsav