News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

uBBC help needed

Started by NiXnAx, December 31, 2004, 07:45:44 AM

Previous topic - Next topic

NiXnAx

I'm trying to write a new UBBC tag, that allows me to write the username or the userid of a user into a [name=<username>] witch would give you a link to that users profile and the realName of the user. The code I have now is like this: if(isset($add['[name='])){
$arr1[] = '~\[name=(.+?)\]~i';
global $realNameBB;
loadRealName($1);
$arr2[] = isset($disabled['name']) ? '$1' : '<a href="$scripturl?action=profile;u=' . $realNameBB['ID_MEMBER'] . '">' . $realNameBB['realName'] . '</a>';
}


But I cant use the Load.php file to have the sql query in, because subs.php is loaded before that one. So I added the loadRealName function to the top of Subs.php

// Load the realName and usernumber of a user
function loadRealName($lusername)
{
global $realNameBB, $db_prefix;

//the sqlquery
$request = db_query("
SELECT realName, ID_MEMBER
  FROM {$db_prefix}members
WHERE memberName=$lusername",__FILE__, __LINE__);

$row = mysql_fetch_assoc($request);
$realNameBB[] = array(
'ID_MEMBER' => $row['ID_MEMBER'],
'realName' => $row['realName']);

return;
}


There is one slight problem with the code, it seem like it can't get the $1 variable from the [name=<username>] tag

Anyone that have any inputs to solve this?

OvermindDL1

#1
Just for note, subs.php may be loaded before load.php, but the parse function is not called till much later, so no problem there. Second, note that is for FasterParseCode, not stock SMF.  Also, choose either ID or name, or do them seperate, like one for [name=] and the id in [nameid=].  Also probobly be better to use a tag named something like [profilelink=] instead (or [profilelinkid=] of course) to distinguish things better.

NiXnAx

I get this error when I try to load the board:Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/silentin/public_html/smf/Sources/Subs.php on line 1129
Line 1129 is where the loadRealName($1); is.

[Unknown]

There are simpler ways... I've got a "Wiki links" mod that you could adapt to this.  It's syntax is like this:

[[member:NiXnAx]]

NiXnAx

It's not hard to change that to be:

[name=NiXnAx]

As for your problem specifically, this is not perl - there is no $1 variable.

-[Unknown]

Trekkie101

The Wiki Links mod should be a feature in SMF for topics, its something ive nerver seen in a BB system before and many may change just for that reason.

Advertisement: