Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: NanoSector on February 20, 2011, 02:23:02 PM

Title: UserID tag
Post by: NanoSector on February 20, 2011, 02:23:02 PM
Can someone move this to Tips and Tricks? Thank you.

The UserID tag allows you to easily link to an user's ID.
Name support soon!

How to install:
Follow these steps:
Find (Subs.php):
array(
'tag' => 'white',
'before' => '<span style="color: white;" class="bbc_color">',
'after' => '</span>',
),


Replace (Subs.php):
array(
'tag' => 'white',
'before' => '<span style="color: white;" class="bbc_color">',
'after' => '</span>',
),
array(
'tag' => 'userid',
'before' => '<a href="' . $scripturl . '?action=profile;u=$1">';
'after' => '</a>';
),

What about using it?
Use it like this:
[userid=251953]My profile[/userid]
Which will replace the need for such a long line as:
[url=http://www.simplemachines.org/community/index.php?action=profile;u=251953]My profile[/url]
Which is extremely handy if you have a very low post size limit.

So... Is this tested?
How dare you ask this! Of course it is.
Title: Re: UserID tag
Post by: Arantor on February 20, 2011, 02:32:55 PM
QuoteHow dare you ask this! Of course it is.

Did you know you can nest tags inside this one?

What happens if there's a non numeric user id put in the userid tag? What happens if it's a tag itself? Quoted?
Title: Re: UserID tag
Post by: NanoSector on February 20, 2011, 02:34:25 PM
Quote from: Arantor on February 20, 2011, 02:32:55 PM
QuoteHow dare you ask this! Of course it is.

Did you know you can nest tags inside this one?

What happens if there's a non numeric user id put in the userid tag? What happens if it's a tag itself? Quoted?
This was just a sketch and I will be improving it.

I just need a way to check if the userid exists.
Title: Re: UserID tag
Post by: Arantor on February 20, 2011, 02:35:05 PM
Then you'll need to use the validate code and query the database (which is a performance issue waiting to happen)
Title: Re: UserID tag
Post by: NanoSector on February 20, 2011, 02:38:35 PM
Quote from: Arantor on February 20, 2011, 02:35:05 PM
Then you'll need to use the validate code and query the database (which is a performance issue waiting to happen)
Which is why this is an optional option.
Title: Re: UserID tag
Post by: Arantor on February 20, 2011, 02:42:31 PM
In which case you still need to declare the validate function to be able to check if the option is set or not.

Right now though I can't encourage this being moved to tips & tricks because it needs more work. Is it intention that it supports nested tags? If not, if memory serves you should set the type to be unparsed_equals.
Title: Re: UserID tag
Post by: NanoSector on February 20, 2011, 02:44:13 PM
Quote from: Arantor on February 20, 2011, 02:42:31 PM
In which case you still need to declare the validate function to be able to check if the option is set or not.

Right now though I can't encourage this being moved to tips & tricks because it needs more work. Is it intention that it supports nested tags? If not, if memory serves you should set the type to be unparsed_equals.
Fixed in svn.
Title: Re: UserID tag
Post by: DoctorMalboro on February 20, 2011, 03:30:06 PM
You should read the comment in the Subs.php about BBCodes.
Title: Re: UserID tag
Post by: NanoSector on February 20, 2011, 03:32:59 PM
Quote from: DoctorMalboro on February 20, 2011, 03:30:06 PM
You should read the comment in the Subs.php about BBCodes.
QuoteThis is just a sketch

Which means it is made in 1 minute.
Title: Re: UserID tag
Post by: Arantor on February 20, 2011, 05:20:23 PM
QuoteWhich means it is made in 1 minute.

But you say you tested it, and we all assumed you'd tested it thoroughly...
Title: Re: UserID tag
Post by: NanoSector on February 21, 2011, 03:49:27 AM
Quote from: Arantor on February 20, 2011, 05:20:23 PM
QuoteWhich means it is made in 1 minute.

But you say you tested it, and we all assumed you'd tested it thoroughly...
Made is something else then tested.
Title: Re: UserID tag
Post by: Arantor on February 21, 2011, 04:26:13 AM
But from your FIRST POST:

QuoteSo... Is this tested?
How dare you ask this! Of course it is.

Make your mind up!
Title: Re: UserID tag
Post by: NanoSector on February 21, 2011, 07:09:31 AM
Quote from: Arantor on February 21, 2011, 04:26:13 AM
But from your FIRST POST:

QuoteSo... Is this tested?
How dare you ask this! Of course it is.

Make your mind up!
QuoteMade is something different then tested.

Which is my point. Testing took way longer then making.
Title: Re: UserID tag
Post by: Arantor on February 21, 2011, 07:11:05 AM
Argh. So you've posted something that you claim to have tested, but not tested very thoroughly because 'it's just an outline'... why not wait until it was more polished before posting?
Title: Re: UserID tag
Post by: NanoSector on February 21, 2011, 07:14:40 AM
Quote from: Arantor on February 21, 2011, 07:11:05 AM
Argh. So you've posted something that you claim to have tested, but not tested very thoroughly because 'it's just an outline'... why not wait until it was more polished before posting?
Because I could not save my progress: shared computer. It would be very dangerous to save it on THAT computer!
Title: Re: UserID tag
Post by: Arantor on February 21, 2011, 07:16:23 AM
Ah, I see. Hmm, may have been best for a 'coding discussion' topic then, rather than presenting it as a fully ready to go tip & trick.

If only there were support for drafts in SMF core...
Title: Re: UserID tag
Post by: NanoSector on February 21, 2011, 07:34:18 AM
Quote from: Arantor on February 21, 2011, 07:16:23 AM
Ah, I see. Hmm, may have been best for a 'coding discussion' topic then, rather than presenting it as a fully ready to go tip & trick.

If only there were support for drafts in SMF core...
It is not fully, I must admit. But it can be used if you do it right.
Title: Re: UserID tag
Post by: DoctorMalboro on February 21, 2011, 11:24:44 AM
you don't share a draft until it's completely finished... no matter how small can it be. It's like doing your homework half and in a dirty paper.
Title: Re: UserID tag
Post by: All Colours Sam on February 21, 2011, 11:28:11 AM
also there's already a mod for this:  http://custom.simplemachines.org/mods/index.php?mod=1367   that mod covers this and also has support for names.
Title: Re: UserID tag
Post by: NanoSector on February 22, 2011, 03:31:33 AM
Quote from: DoctorMalboro on February 21, 2011, 11:24:44 AM
you don't share a draft until it's completely finished... no matter how small can it be. It's like doing your homework half and in a dirty paper.
Ever used your eyes doctor?

@ above: when I last looked that mod was not there.