Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

comments_tags_to_links()

Description

Parse a comment and replace and add links to any user, resource and collection tags

Parameters

ColumnTypeDefaultDescription
string $text: preg_replace'/@\S+/s'
href '
$text; preg_replace'/r[0-9]{1
}/si'
# $text; str_replace"[BASEURLSHORT]"
$baseurl_short
// $text;
or collection
true
to defaults
be will
$bcollection_mode false
$bRecursive true
$level 1
$text string The input text e.g. the body of the comment

Location

include/comment_functions.php lines 184 to 195

Definition

 
function comments_tags_to_links($text): string
    
{
    global 
$baseurl_short;
    
$text=preg_replace('/@(\S+)/s''<a href="[BASEURLSHORT]pages/user/user_profile.php?username=$1">@$1</a>'$text);

    
$text=preg_replace('/r([0-9]{1,})/si''<a href="[BASEURLSHORT]?r=$1">r$1</a>'$text); # r12345 to resource link

    
$text=preg_replace('/c([0-9]{1,})/si''<a href="[BASEURLSHORT]?c=$1">c$1</a>'$text); # c12345 to collection link

    
$text str_replace("[BASEURLSHORT]",$baseurl_short,$text); // Replacing this earlier can cause issues
    
return $text;
    }

This article was last updated 19th March 2024 03:05 Europe/London time based on the source file dated 8th March 2024 15:10 Europe/London time.