3.1.x SnippetsShow external link names

Snippets
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Show external link names

Post by martin »

The finds maybe a little different in 3.1.x but i'm sure you can work it out (3.1.x has an extra line in the finds)

Open: includes/functions_content.php
Find This may be a partial find and not the whole line

Code: Select all

/**
* A subroutine of make_clickable used with preg_replace
Add before Add these lines on a new blank line before the preceding line(s) to find

Code: Select all

/**
* A subroutine of make_clickable to retrieve
* titles of links posted
*
*/
function make_title_link($url, $text)
{
   $handle = @file_get_contents($url);
   if(!empty($handle))
   {
      preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i', $handle, $matches );
      if(isset($matches[3]))
      {
         $handle = $handle;
      }
      else
      {
         $handle = mb_convert_encoding($handle, 'HTML-ENTITIES', "UTF-8");
      }

      $dom = new DOMDocument();
      if (@$dom->loadHTML($handle))
      {
         $xpath = new DOMXPath($dom);
         if (!empty($xpath->query('//title')->item(0)->nodeValue))
         {
            $title = $xpath->query('//title')->item(0)->nodeValue;
            $text = str_replace("\n", " ",$title);
            return $text;
         }
      }
   }
   return $text;
}
Find This may be a partial find and not the whole line

Code: Select all

$tag	= 'm';
			$text	= $short_url;
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

$text = make_title_link($url, $text);
Find This may be a partial find and not the whole line

Code: Select all

$url	= 'http://' . $url;
			$text	= $short_url;
Add after Add these lines on a new blank line after the preceding line(s) to find

Code: Select all

$text = make_title_link($url, $text);
Demo if installed here Blades-place - Index page

Electronics, Cars, Fashion, Collectibles, Coupons and More | eBay

YouTube to mp3 Converter
Image

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

dsaf
Users
Users
Status: Offline
User theme: Dark
Posts: 33
Joined: Jan 17th, '15, 16:51
    Windows 7 Chrome

Re: Show external link names

Post by dsaf »

Your a good man, Thankyou!

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Jaantje
Users
Users
Status: Offline
User theme: Dark
Posts: 356
Joined: Nov 2nd, '14, 20:25
    Windows 8.1 Chrome

Re: Show external link names

Post by Jaantje »

martin works great :thumbup:
Grreeetttttzzzzz, Jaantje

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Show external link names

Post by martin »

:buigen:

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Solidjeuh
Users
Users
Status: Offline
User theme: Dark
Posts: 348
Joined: Dec 13th, '14, 01:40
    Windows 10 Firefox

Re: Show external link names

Post by Solidjeuh »

Maybe I'm blind.. :rolling:
But is there also a topic for 'internal link' ?
Forum voor NL Extensie vertalingen ---> https://www.supportforum.be
----------------------------------------------------------------------------

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Show external link names

Post by martin »

Forum Link to Topic Title now (ABD) still WORKS - Martins-Place.dyndns.info :rolling: wrong site mate.

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Solidjeuh
Users
Users
Status: Offline
User theme: Dark
Posts: 348
Joined: Dec 13th, '14, 01:40
    Windows 10 Firefox

Re: Show external link names

Post by Solidjeuh »

Woepssssss :rolling: Thank you :eusa_dance:

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Show external link names

Post by martin »

Let me know if any edits need fixing and il bring it up to date.

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Solidjeuh
Users
Users
Status: Offline
User theme: Dark
Posts: 348
Joined: Dec 13th, '14, 01:40
    Windows 10 Firefox

Re: Show external link names

Post by Solidjeuh »

martin wrote:let me know if any edits need fixing and il bring it up to date.
Tried it, and it works.. :eusa_dance:

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Show external link names

Post by martin »

:thumbup:

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Linux Chrome

Re: Show external link names

Post by martin »

Cough wanna go one better Search icon on internal links - Martins-Place.dyndns.info

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Solidjeuh
Users
Users
Status: Offline
User theme: Dark
Posts: 348
Joined: Dec 13th, '14, 01:40
    Windows 10 Firefox

Re: Show external link names

Post by Solidjeuh »

I had to undo these edits
I use 'OneAll Social Login'
And it takes the memberlist 10 to 30 seconds to load because of the 'website / facebook links'.
And not just those facebook links, but also all others

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Anuj Dhawan
Users
Users
Status: Offline
User theme: Dark
Posts: 109
Joined: Aug 31st, '15, 08:32
    Windows 7 Chrome

Re: Show external link names

Post by Anuj Dhawan »

Hi,

Can this be converted to an extension? Manual edits are pain in a$$.

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

RMcGirr83
Users
Users
Status: Offline
User theme: Dark
Posts: 3
Joined: Nov 6th, '15, 11:38
    Windows 10 Firefox

Re: Show external link names

Post by RMcGirr83 »

And more code that looks very familiar to me. /me wonders if dmzx and martin scrapped my entire forum when it used to be up.
You do not have the required permissions to view the files attached to this post! Maybe your post count is too low.

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Template.php on line 359: Array to string conversion
Array

Topic Author
martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5132
Joined: Apr 6th, '14, 14:12
    Windows 10 Chrome

Re: Show external link names

Post by martin »

Naaa It's on phpmodders lol note for 3.1 the finds are a little different tho.