[Snippet] Website Title as Link

Little Mods and Snips 3

[Snippet] Website Title as Link

Postby Sekuro » 18 Dec 2011, 21:55

Website Title as Link

With this Snippet u can post a link, that automatically shows the link-title of the website as link-description.

Example:

This Link..
Code: Select all
[url_title]http://4seven.bplaced.net/forum/6test/viewtopic.php?f=6&t=116[/url_title]

produces..
[Snippet] Website Title as Link

Screen: follows

Requirement: allow_url_fopen must be activated



Instruction:

1. Make a BBCode

BBCode usage
Code: Select all
[url_title]{URL}[/url_title]


HTML replacement
Code: Select all
{URL}


2. Open

viewtopic.php

Find

Code: Select all
// Output the posts
$first_unread = $post_unread = false;
for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
{


Before Add

Code: Select all
// Link as Website Title / 4seven / 2009
function getTitleTag($uwebsite) {   
   $uhtml = implode("", file(html_entity_decode($uwebsite)));
   if (preg_match("/<title>(.*)<\/title>/isU", $uhtml, $utitle)){
   $utitletag = trim($utitle[1]);
   return '<a href="' . $uwebsite . '">' . $utitletag . '</a>';}}
// Link as Website Title / 4seven / 2009


Find

Code: Select all
$message = censor_text($row['post_text']);


After Add

Code: Select all
// Link as Website Title / 4seven / 2009
if((preg_match("#\[url_title:#", $message)) && preg_match("#\[\/url_title:#", $message)){
$message = preg_replace("/\[url_title(.*?)\](.*?)\[\/url_title(.*?)\]/eU", 'getTitleTag("\\2")', $message);}
// Link as Website Title / 4seven / 2009


3. Clear all Caches
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900


Return to Snip Cl@ss III

Who is online

Users browsing this forum: No registered users and 2 guests

cron