Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2011, 07:04 PM
Chris8's Avatar
Chris8 Chris8 is offline
 
Join Date: Nov 2009
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Parsing BBcodes in custom fields on member profile page.

People of vB perhaps you will be able to help me at least this time. I'm struggling with this problem since two days or so and I still cannot get it to work. I'm using vbulletin 3.8 series.

How the heck I will get bbcodes to work in custom fields in members profile. I'm trying to turn on smiles, urls and image parsing. I've digged various tutorials and plugins and and I've done a several mixes of them all and non of it works. I must be missing something obvious.

Here are some sample plugins I've tried.

PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="parse_member_bbcode" active="1">
    <title>Parse BBCode in member profile fields</title>
    <description><![CDATA[Parse bbcode for profile fields in members profiles.]]></description>
    <version>1.0.0</version>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1">
            <title>Parse BBCode in extra profile fields</title>
            <hookname>member_complete</hookname>
            <phpcode><![CDATA[$userinfo['field7'] = $parser->do_parse($userinfo['field7']);
$userinfo['field8'] = $parser->do_parse($userinfo['field8']);
$userinfo['field9'] = $parser->do_parse($userinfo['field9']);
$userinfo['field10'] = $parser->do_parse($userinfo['field10']);
$userinfo['field11'] = $parser->do_parse($userinfo['field11']);]]></phpcode>
        </plugin>
        <plugin active="1">
            <title>Parse BBCode in custom profile fields</title>
            <hookname>member_customfields</hookname>
            <phpcode><![CDATA[$profilefield['value'] = $parser->do_parse($profilefield['value']);]]></phpcode>
        </plugin>
        <plugin active="1">
            <title>Init BBCode-Parser</title>
            <hookname>member_start</hookname>
            <phpcode><![CDATA[require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
</product>

not working
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="bbcodes_style_profile" active="1">
    <title>Parse BBCode in Custom Profile Fields</title>
    <description>Give your users the full effect by letting them use BB Code in their profile.</description>
    <version>1.1</version>
    <codes>
    </codes>
    <templates>
    </templates>
    <plugins>
        <plugin active="1">
            <title>Parse BBCode for Custom Profile Fields</title>
            <hookname>member_customfields</hookname>
            <phpcode><![CDATA[if (!is_object($bbcode_parser))
    {
        require_once(DIR . '/includes/class_bbcode.php');
        $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
    }
     $profilefield['value'] = $bbcode_parser->parse($userinfo["$profilefieldname"],0, true);]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
</product>
members page goes blank


in member_complete
PHP Code:
if ($userinfo['field7'])
{
if (!
is_object($bbcode_parser))
{
require_once(
DIR '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
}
$userinfo['field7'] = $bbcode_parser->parse($userinfo['field7'],0true);

not working

another one in member_complete
PHP Code:
require_once(DIR '/includes/class_bbcode.php'); 
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

$post[field7] = $parser->do_parse($post[field7], falsefalsetruefalsefalsetrue); 

Not working and so on... I've used of course a proper field number and bbcode parameters. So any help would be appreciated. I would be grateful if you could share a solution that will work in 100% percent.

Please, help me.
Reply With Quote
  #2  
Old 07-26-2011, 09:17 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This seems to work: use hook location member_customfields and this code:

PHP Code:
if ($profilefield['profilefieldid'] == 7)
{
    global 
$vbulletin;
    require_once(
DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$profilefield['value']= $bbcode_parser->parse(unhtmlspecialchars($profilefield['value']),0true);


I tried it out but did not do much testing.
Reply With Quote
  #3  
Old 07-28-2011, 04:14 PM
Chris8's Avatar
Chris8 Chris8 is offline
 
Join Date: Nov 2009
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome, this one works! Thank you very much kh99! Folks like you restore my faith in people.
Reply With Quote
  #4  
Old 07-28-2011, 06:04 PM
GavoTrav's Avatar
GavoTrav GavoTrav is offline
 
Join Date: Jun 2011
Location: Ireland
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kh99 has already answered but this is another way!

NON-VB

Add it to the top of the template where it shows/pastes

PHP Code:

Just include the string
<?php include 'bb2html.php';?>
And to call it simply write
<?php $htmltext bb2html($bbtext);?>
[/code]

Then upload this file:

Call it: bb2html.php
[code]
<?php

// A simple FAST parser to convert BBCode to HTML
// Trade-in more restrictive grammar for speed and simplicty
//
// Syntax Sample:
// --------------
// [img]http://pvhax.com/images/star.gif[/img]
// [url="http://pvhax.com"]PvHax[/url]
// [mail="webmaster@pvhax.com"]Webmaster[/mail]
// [size="25"]HUGE[/size]
// [color="red"]RED[/color]
// [b]bold[/b]
// [i]italic[/i]
// [u]underline[/u]
//[list][*]item[*]item[*]item[/list]// [code]value="123";[/code]
// [quote]John said yadda yadda yadda[/quote]
//
// Usage:
// ------
// <?php include 'bb2html.php'; 
?>
// <?php $htmltext bb2html($bbtext); ?>


function bb2html($text)
{
  $bbcode = array("<", ">",
                "[list]", "[*]", "[/list]", 
                "[img]", "[/img]", 
                "[b]", "[/b]", 
                "[u]", "[/u]", 
                "[i]", "[/i]",
                '[color="', "[/color]",
                "[size=\"", "[/size]",
                '[url="', "[/url]",
                "[mail=\"", "[/mail]",
                "[code]", "[/code]",
                "[quote]", "[/quote]",
                '"]');
  $htmlcode = array("&lt;", "&gt;",
                "<ul>", "<li>", "</ul>", 
                "<img src=\"", "\">", 
                "<b>", "</b>", 
                "<u>", "</u>", 
                "<i>", "</i>",
                "<span style=\"color:", "</span>",
                "<span style=\"font-size:", "</span>",
                '<a href="', "</a>",
                "<a href=\"mailto:", "</a>",
                "<code>", "</code>",
                "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>",
                '">');
  $newtext = str_replace($bbcode, $htmlcode, $text);
  $newtext = nl2br($newtext);//second pass
  return $newtext;
}
?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:47 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.05094 seconds
  • Memory Usage 2,224KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete