vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   BBcode help (https://vborg.vbsupport.ru/showthread.php?t=221570)

wipedout 08-23-2009 03:25 PM

BBcode help
 
I need help with a bbcode for users avatar and one for username with html markup, i want to be able to do either
Code:

[user]wipedout[/user]
to show my username with my html markups and [usericon]someguy[/usericon] to show the someguys of avatar.

James Birkett 08-23-2009 03:44 PM

1 Attachment(s)
I'll help you do it with plug-ins:

Hook: bbcode_create
Title: [user] BBCode
PHP Code:
PHP Code:

if ($this->is_wysiwyg()) $this->unparsed_tags[] = 'user';

if (!
function_exists('nex_fetch_musername'))
{
    function 
nex_fetch_musername(&$parser$userid$title='')
    {
        global 
$vbulletin$db;
        
# check if we have a username or userid
        
$wesearch is_numeric($userid) ? 'userid' 'username';
        if(
$user $db->query_first_slave("
            SELECT * FROM " 
TABLE_PREFIX "user
            WHERE " 
$wesearch " = '" $userid "'
        "
))
        {
            
$musername fetch_musername($user);
            return 
'<a href="' $vbulletin->options['bburl'] . '/member.php?u=' $user['userid'] . '">' $musername '</a>';
        }
        return 
$userid;
    }
    function 
nex_fetch_musername_option(&$parser$title=''$userid)
    {
        global 
$vbulletin$db;
        
# check if we have a username or userid
        
$wesearch is_numeric($userid) ? 'userid' 'username';
        if(
$user $db->query_first_slave("
            SELECT * FROM " 
TABLE_PREFIX "user
            WHERE " 
$wesearch " = '" $userid "'
        "
))
        {
            if(
$title != ''$user['username'] = $title;
            
$musername fetch_musername($user);
            return 
'<a href="' $vbulletin->options['bburl'] . '/member.php?u=' $user['userid'] . '">' $musername '</a>';
        }
        return 
$userid;
    }
}

// [USER]
$this->tag_list['no_option']['user'] = array(
    
'callback' => 'handle_external',
    
'strip_empty' => true,
    
'stop_parse' => false,
    
'disable_smilies' => false,
    
'disable_wordwrap' => true,
    
'strip_space_after' => 0,
    
'external_callback' => 'nex_fetch_musername'
);
// [USER=XXX]
$this->tag_list['option']['user'] = array(
    
'callback' => 'handle_external',
    
'strip_empty' => true,
    
'stop_parse' => false,
    
'disable_smilies' => false,
    
'disable_wordwrap' => true,
    
'strip_space_after' => 0,
    
'external_callback' => 'nex_fetch_musername_option'
); 


Note: This isn't my code - it works on vBulletin 3.8.3 however.

An XML is also attached if you don't want to do it manually.

wipedout 08-23-2009 05:43 PM

Yea that solves part of the problem, but that leaves the [usericon] bbcode.

James Birkett 08-23-2009 06:01 PM

Try this:
Create new BBCode
Title: Usericon
BBCode Tag Name: usericon
Replacement:
<img src="image.php?u={param}" />
Example:
[usericon]1[/usericon]
Description:
Put user ID in between usericon BBCodes to get their avatar.

How to use:
[usericon]{User ID}[/usericon]

wipedout 08-23-2009 06:05 PM

does not work due to the fact that im using avatars in filesystem.

James Birkett 08-23-2009 06:14 PM

Is there a recurring URL to get to the avatar?

wipedout 08-23-2009 07:43 PM

yea there is, im just not sure how vbulletin grabs the url...

James Birkett 08-23-2009 07:45 PM

Post a URL to a member's avatar.

wipedout 08-23-2009 07:56 PM

<a href="http://forums.thefurryden.net/customavatars/thumbs/avatar4_3.gif" target="_blank">http://forums.thefurryden.net/custom.../avatar4_3.gif</a>

James Birkett 08-23-2009 08:01 PM

Hmm, I'm not sure on how filesystem avatars are stored. Does the URL have any relevance to the user's profile/user ID?

wipedout 08-23-2009 08:06 PM

not really.

wipedout 08-25-2009 10:19 AM

Bump for knowledge.

Lynne 08-25-2009 02:48 PM

Quote:

Originally Posted by James Birkett (Post 1872915)
Hmm, I'm not sure on how filesystem avatars are stored. Does the URL have any relevance to the user's profile/user ID?

Yes, they have relevance.

avatarx_y.gif

The x in the image name is the userid and the y is from user.avatarrevision. You would have to query the databae to get the avatarrevision.

James Birkett 08-25-2009 03:56 PM

Wipedout you have 2 options:
Move avatars back to the database and use the BBCode I provided below
OR
Create a hook on bbcode_create that uses mysql queries on the user.avatarrevision.

Thanks Lynne.

wipedout 08-25-2009 09:51 PM

Quote:

Originally Posted by James Birkett (Post 1874156)
Wipedout you have 2 options:
Move avatars back to the database and use the BBCode I provided below
OR
Create a hook on bbcode_create that uses mysql queries on the user.avatarrevision.

Thanks Lynne.

Think you could help me make a product that make me be able to use username instead of user id? then i'd be okay with moving it back to database.


All times are GMT. The time now is 04:16 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03354 seconds
  • Memory Usage 1,769KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (15)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete