copy the link of the post

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
halil16
Registered User
Posts: 1266
Joined: Fri Jul 24, 2020 11:30 pm
Location: Turkiye
Name: Halil
Contact:

copy the link of the post

Post by halil16 »

Hi,
I have set a link to the post buttons that will copy the link of the post. I did this with the following codes:

Code: Select all

<li><a href="https://mywebsitess112.com/forum/<!-- IF postrow.S_FIRST_ROW -->viewtopic.php?t={TOPIC_ID}<!-- ELSE -->viewtopic.php?p={postrow.POST_ID}#p{postrow.POST_ID}<!-- ENDIF -->" class="kobyalandiyigenim" onclick="copyURI(event)"><i class="fa fa-link fa-fw" aria-hidden="true"></i><!-- IF postrow.S_FIRST_ROW -->Copy topic link<!-- ELSE -->Copy post link<!-- ENDIF --></a></li>

Code: Select all

<script>
function copyURI(evt) {
    evt.preventDefault();
    navigator.clipboard.writeText(evt.target.getAttribute('href')).then(() => {
      /* clipboard successfully set */
    }, () => {
      /* clipboard write failed */
    });
}
</script>
I share this both for those who need it to use and for correction if there is a defect or mistake.

Kind regards.
* Hire me at fiverr for your phpBB board.
"The day we will need ideas more than possessions, we will find the secret to true wealth." - Peyami Safa
I'm learning English...
Contributions: #Hashtag, Elegance, Latte
Post Reply

Return to “phpBB Custom Coding”