In this post, I want to share how we can add the current userid to the 'Sign out' action menu item which is part of the branding.
Fluid:
Classic:
What is the benefit?
The reason I find this useful is because we can quickly hover over the action menu on any page and find out who we are logged in as (particularly when we are testing with multiple userids). Further, in the past we had a lot more real estate in the Branding header and we could add a greeting message to provide some flavor of personalization/user identification. But with the New User Interface (NUI) navigation and branding, it is not ideal to use up the Branding header to display a lengthy (space consuming) greeting. This 'Sign out' customization will provide a user specific label.
Implementation Details:
Environment:
- CS 9.2 PUM Image 4
- PeopleTools 8.54.12
Project on GitHub:
https://github.com/SasankVemana/Branding-Signout-Label-Customization
'Sign out' label customization in Fluid:
Record: PT_WORK
Field: PT_BUTTON_LOGOUT
Event: RowInit
Note: Add the peoplecode to PT_WORK.PT_BUTTON_LOGOUT.RowInit
'Sign out' label in Classic:
In Classic, we can update the 'Sign out' label without any customization using the Branding Framework.
App Package Implementation for Custom Sign out:
Note: This App Class was cloned from PTBR_BRANDING.SystemElement.SignOutLink and updated to include the %operatorid on the label.
App Package:
Create New Branding Element Type:
PeopleTools > Branding > System Data > Define Element Types
Remove delivered 'Sign out' from the Custom Branding Header:
Note: This is assuming we used a custom branding header to define our Branding Theme. In my case, I used the following approach: PeopleTools 8.55 Branding
- Delete 'pthdr2signout' element from the custom header (CSK_HEADER_FLUID).
- Save the custom header (CSK_HEADER_FLUID).
Add Custom 'Sign out' element to the Branding Header:
Fluid:
Classic:
What is the benefit?
The reason I find this useful is because we can quickly hover over the action menu on any page and find out who we are logged in as (particularly when we are testing with multiple userids). Further, in the past we had a lot more real estate in the Branding header and we could add a greeting message to provide some flavor of personalization/user identification. But with the New User Interface (NUI) navigation and branding, it is not ideal to use up the Branding header to display a lengthy (space consuming) greeting. This 'Sign out' customization will provide a user specific label.
Implementation Details:
Environment:
- CS 9.2 PUM Image 4
- PeopleTools 8.54.12
Project on GitHub:
https://github.com/SasankVemana/Branding-Signout-Label-Customization
'Sign out' label customization in Fluid:
Record: PT_WORK
Field: PT_BUTTON_LOGOUT
Event: RowInit
'Sign out' label in Classic:
In Classic, we can update the 'Sign out' label without any customization using the Branding Framework.
App Package Implementation for Custom Sign out:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PTBR_BRANDING:Elements:BaseElement; | |
import PTBR_BRANDING:SystemElements:SystemLink; | |
import PTBR_BRANDING:SystemElements:SignOutLink; | |
/** | |
* SignOutLink Class | |
*/ | |
class SignOutLink extends PTBR_BRANDING:SystemElements:SystemLink | |
/* --- Properties --- */ | |
/* --- Methods --- */ | |
method SignOutLink(&pId As string); | |
method clone() Returns PTBR_BRANDING:Elements:BaseElement; | |
protected | |
/* --- Protected properties --- */ | |
/* --- Protected Methods --- */ | |
method setupLink(&pPreview As boolean); | |
end-class; | |
/** | |
* Constructor | |
* | |
* @param pId ID of the object. | |
* | |
*/ | |
method SignOutLink | |
/+ &pId as String +/ | |
%Super = create PTBR_BRANDING:SystemElements:SystemLink(&pId); | |
%This.setElementType("SignOutLink"); | |
rem %this.setAdvancedOptionsPage (Page.); | |
/* Initialize attributes */ | |
%This.Label.setMessageText(95, 408, "Sign Out"); | |
end-method; | |
/** | |
* Make an exact copy of this object. | |
* NOTE: Only create the object here, do not copy any class properties. | |
* If there are new class properties, override the copyProperties | |
* method and do it there. Should invoke the %Super.copyProperties | |
* in that method though. | |
* | |
* @return BaseElement New object exactly matching this object. | |
* | |
*/ | |
method clone | |
/+ Returns PTBR_BRANDING:Elements:BaseElement +/ | |
/+ Extends/implements PTBR_BRANDING:SystemElements:SystemLink.clone +/ | |
Local PTBR_BRANDING:SystemElements:SignOutLink &newObj = create PTBR_BRANDING:SystemElements:SignOutLink(%This.ID); | |
/* Call the copy properties function */ | |
%This.copyProperties(&newObj); | |
Return &newObj; | |
end-method; | |
/***************************** | |
* Protected methods | |
*****************************/ | |
/** | |
* Setup the link properties | |
* | |
*/ | |
method setupLink | |
/+ &pPreview as Boolean +/ | |
Local string &linkUrl = ""; | |
Local integer &pos1, &pos2, &pos3, &i; | |
Local string &siteName, &char, &parseSiteName; | |
&linkUrl = %Request.LogoutURL; | |
/* Remove session number (_nn) from the URL */ | |
&pos1 = (Find("/psp/", &linkUrl) + 5); | |
&pos2 = Find("/", &linkUrl, &pos1); | |
&siteName = Substring(&linkUrl, &pos1, &pos2 - &pos1); | |
&pos3 = 0; | |
For &i = 1 To Len(&siteName) | |
&char = Substring(&siteName, &i, 1); | |
If &char = "_" Then | |
&pos3 = &i; | |
End-If; | |
End-For; | |
If (&pos3 <> 0) Then | |
&parseSiteName = Substring(&siteName, &pos3 + 1, Len(&siteName) - &pos3); | |
If IsNumber(&parseSiteName) Then | |
&siteName = Substring(&siteName, 1, &pos3 - 1); | |
End-If; | |
End-If; | |
&linkUrl = Substring(&linkUrl, 0, &pos1 - 1) | &siteName | Substring(&linkUrl, &pos2, Len(&linkUrl) - (&pos2 - 1)); | |
%This.URL = &linkUrl; | |
%This.Label.setText("Sign Out (" | %OperatorId | ")"); | |
end-method; |
App Package:
Create New Branding Element Type:
PeopleTools > Branding > System Data > Define Element Types
Remove delivered 'Sign out' from the Custom Branding Header:
Note: This is assuming we used a custom branding header to define our Branding Theme. In my case, I used the following approach: PeopleTools 8.55 Branding
- Delete 'pthdr2signout' element from the custom header (CSK_HEADER_FLUID).
- Save the custom header (CSK_HEADER_FLUID).
Add Custom 'Sign out' element to the Branding Header:
No comments:
Post a Comment