Monday, July 15, 2019

Tips and Tricks : How to hide other feature in Chatter Feed in Visualforce page WITHOUT using JQuery ?

Business Requirement

To only enable Post features in Chatter Feed in Visualforce. Other features such as Poll, Upload File etc should be invisible to user  so that user only able to Post in Chatter Feed.

This is just to give idea that you can hide some of standard css element using style css with !IMPORTANT tag if it 's still not update as you want to or you can hide it using javascript during onload.

Example to hide some standard elements using style .


1
2
3
4
5
6
7
8
/**code to hide file upload in chatter comment section **/
.cxcontentcommentactiontext {
display:none;
}

.cxcontentcommentactionimg {
display:none;
}

Example to hide some of element in Chatter Feed using Javascript
1
2
3
4
5
6
7
window.onload = function() {
//this is to hide File upload and any feature except post in Chatter feed.
   const chatterList = document.querySelectorAll('.publisherFeedItemTypeChoices li');
   chatterList[1].style.display='none';
   chatterList[2].style.display='none';
   chatterList[3].style.display='none';
}

Basically if you can see which Element you want to hide. End result should be like below.


No comments:

Post a Comment