[3.2] complete links in postings

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
Eddie Felson
Registered User
Posts: 16
Joined: Thu Sep 04, 2014 7:59 pm

[3.2] complete links in postings

Post by Eddie Felson »

Hi,
to show complete links in postings, I know the folowing code (works fine with 3.1).

includes/functions_content.php:

Find:

Code: Select all

$short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;
Replace:

Code: Select all

$short_url = $url;
Code worked for new or resaved posts

Since the update to 3.21 the code doesn't work.
Does everyone a solution?

Regards
Last edited by JimA on Sat Sep 16, 2017 5:57 pm, edited 1 time in total.
Reason: Moved from Support to Custom Coding
User avatar
david63
Registered User
Posts: 18577
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: [3.2] complete links in postings

Post by david63 »

Out of interest why? What difference does it make?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 4579
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [3.2] complete links in postings

Post by kasimi »

  • Open [root]/phpbb/textformatter/s9e/link_helper.php
  • Find

    Code: Select all

    if (utf8_strlen($text) > 55)
  • Replace with

    Code: Select all

    if (false)
User avatar
JoshyPHP
Code Contributor
Posts: 1177
Joined: Mon Jul 11, 2011 12:28 am

Re: [3.2] complete links in postings

Post by JoshyPHP »

You can implement it as an extension that removes the template that displays the shortened text.

Code: Select all

class listener implements EventSubscriberInterface
{
	public static function getSubscribedEvents()
	{
		return ['core.text_formatter_s9e_configure_after' => 'onConfigure'];
	}
	public static function onConfigure($event)
	{
		unset($event['configurator']->tags['LINK_TEXT']->template);
	}
}
The added bonus of using this method is that it only changes the way links are displayed, not stored. That means you don't need to reparse old posts when the extension is toggled.
I wrote the thing that does BBCodes in 3.2+.
Eddie Felson
Registered User
Posts: 16
Joined: Thu Sep 04, 2014 7:59 pm

Re: [3.2] complete links in postings

Post by Eddie Felson »

Thanks for the support.

I never worked with own extensions before.

Witch path, filename and extention is needed for the code?
Last edited by Eddie Felson on Sun Sep 17, 2017 5:24 pm, edited 1 time in total.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 22919
Joined: Fri Aug 29, 2008 9:49 am
Location: Watching cricket probably.

Re: [3.2] complete links in postings

Post by Mick »

You can make an extension request if you wish.
"The more connected we get the more alone we become" - Kyle Broflovski©
Eddie Felson
Registered User
Posts: 16
Joined: Thu Sep 04, 2014 7:59 pm

Re: [3.2] complete links in postings

Post by Eddie Felson »

Hi,
the code from kasimi works fine. thanks

I think this change are important for some forums,
- to easy copy the text including all links as flat text
- to show the forum reader the complete link, so they can decided by them self, if the links looks safe

@Mick
Please could you create an extension?

Regards
User avatar
Mick
Support Team Member
Support Team Member
Posts: 22919
Joined: Fri Aug 29, 2008 9:49 am
Location: Watching cricket probably.

Re: [3.2] complete links in postings

Post by Mick »

No, you need to go to the extensions forums and make a request.
"The more connected we get the more alone we become" - Kyle Broflovski©
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2859
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [3.2] complete links in postings

Post by KaileyT »

https://github.com/kinerity/fulllinks/releases

Works fine in my (limited) testing. Uses JoshyPHP's code.
Kailey Truscott - Community Team
Eddie Felson
Registered User
Posts: 16
Joined: Thu Sep 04, 2014 7:59 pm

Re: [3.2] complete links in postings

Post by Eddie Felson »

@kinerity
Your extension works very well.
When I using the code change, I have to edit all old postings to convert the link format.
With the extension 'fulllinks', the long links appears immediately at all.
For the correct installation was the additional folder /kinerity/ needed.
Full path /ext/kinerity/fulllinks/...

The support here is glorious

thanks
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2859
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [3.2] complete links in postings

Post by KaileyT »

Link has been fixed. Sorry about that folks.
Kailey Truscott - Community Team
WWu777
Registered User
Posts: 789
Joined: Tue Aug 14, 2007 12:40 pm
Contact:

Re: [3.2] complete links in postings

Post by WWu777 »

What if I don't want to show the whole link? I just want to increase the default length at which the link will be shortened. The default is 55 characters right? How do I increase it? I tried to change the 55 number on that code but it didn't seem to work.
WWu777
Registered User
Posts: 789
Joined: Tue Aug 14, 2007 12:40 pm
Contact:

Re: [3.2] complete links in postings

Post by WWu777 »

Eddie Felson wrote:
Sat Sep 16, 2017 5:37 pm
Hi,
to show complete links in postings, I know the folowing code (works fine with 3.1).

includes/functions_content.php:

Find:

Code: Select all

$short_url = (utf8_strlen($url) > 55) ? utf8_substr($url, 0, 39) . ' ... ' . utf8_substr($url, -10) : $url;
Replace:

Code: Select all

$short_url = $url;
Code worked for new or resaved posts

Since the update to 3.21 the code doesn't work.
Does everyone a solution?

Regards
So if the hyperlink is more than 55 characters it gets shortened right? Can I just increase the limit to something above 55? Will this work in phpbb 3.3 too?
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2859
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [3.2] complete links in postings

Post by KaileyT »

WWu777 wrote:
Tue Apr 07, 2020 1:51 am
So if the hyperlink is more than 55 characters it gets shortened right? Can I just increase the limit to something above 55? Will this work in phpbb 3.3 too?
This extension still works in 3.3 https://www.phpbb.com/customise/db/exte ... ull_links/
Kailey Truscott - Community Team
WWu777
Registered User
Posts: 789
Joined: Tue Aug 14, 2007 12:40 pm
Contact:

Re: [3.2] complete links in postings

Post by WWu777 »

kinerity wrote:
Tue Apr 07, 2020 3:36 am
WWu777 wrote:
Tue Apr 07, 2020 1:51 am
So if the hyperlink is more than 55 characters it gets shortened right? Can I just increase the limit to something above 55? Will this work in phpbb 3.3 too?
This extension still works in 3.3 https://www.phpbb.com/customise/db/exte ... ull_links/
Thanks. But what if the link is so long that it goes off the page? Would it wrap around or go off screen and increase the width of the forum topic page?

I was hoping just to increase the limit of the link shortening, not disable it entirely.
Post Reply

Return to “phpBB Custom Coding”