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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2009, 05:39 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Please help. Need to parse bbcode in a user profile field and pass it to a template.

I posted a few days ago about this, but a member told me about user profile fields. Very helpful. I've managed to get the profile field to show in the template that I want (member info), however, when I add BBcode or html to the profile field, vbulletin just shows the code in the browser and doesn't parse it.

I know the dangers of html in vbulletin. I'm just trying things to see what works and what doesn't.

So what I need to do is this... I need to be able to show my profile field in the template but have it be parsed. I figure a plugin is needed, but I can't seem to get the code to work. I've read mod about parsing bbcode.

Code:
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($text, $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable);
I just don't really know where that needs to go for the variable to get "back" to the template. I figure there is an eval() that needs to be there.

I know the template, plugin, and vbulletin "all become one" after the server works, but I can't grasp the concept well.

Please help.
Reply With Quote
  #2  
Old 03-28-2009, 08:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wrote a mod where I needed to process the bbcode (View all your social group messages) and I copied/modified a function to parse the bbcode:

PHP Code:
function process_message_preview($message)
{
    global 
$vbulletin$vbphrase$stylevar$show;

    require_once(
DIR '/includes/class_bbcode.php');
    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

    
$previewhtml '';
    if (
$previewmessage $bbcode_parser->parse($message['pagetext'], 'socialmessage'$message['disablesmilies'] ? 1))
    {
        
$previewhtml $previewmessage;
    }

    return 
$previewhtml;

The call in the code was something like:
PHP Code:
query
then
    
while ($message $vbulletin->db->fetch_array($messagelist))
    {
.....
        
        
$message['pagetext'] = process_message_preview($message);
eval 
template that uses $message['pagetext'];

So, you look like you are on the right track. You would need to add the call to the function/code prior to the eval statement (like I show above).
Reply With Quote
  #3  
Old 04-03-2009, 09:05 AM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I tried to do what you said. I've got a new profile field (field65) that I've managed to display once on my page using an eval statement, but when I try the following code, I get nothing. I've got my variable $mypage inserted into the MEMBERINFO template. I've been playing with this for about an hour now. I must be off to work. Any ideas?

Code:
function process_message_preview($message)
{
    global $vbulletin, $vbphrase, $stylevar, $show;

    require_once(DIR . '/includes/class_bbcode.php');
    $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

    $previewhtml = '';
    if ($previewmessage = $bbcode_parser->parse($message['pagetext'], 'socialmessage', $message['disablesmilies'] ? 0 : 1))
    {
        $previewhtml = $previewmessage;
    }

    return $previewhtml;
}  

 process_message_preview($message);

$mypage = process_message_preview($vbulletin->userinfo['field65']);

eval MEMBERINFO;
Reply With Quote
  #4  
Old 04-03-2009, 02:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That is not how you eval a template. Take a look in a page like member.php and you'll see these last lines:
PHP Code:
eval('$navbar = "' fetch_template('navbar') . '";');

$templatename 'MEMBERINFO';

(
$hook vBulletinHook::fetch_hook('member_complete')) ? eval($hook) : false;

eval(
'print_output("' fetch_template($templatename) . '");'); 
Reply With Quote
  #5  
Old 04-03-2009, 04:41 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it working! Awesome. Now all I have to do is create a bunch of bbcode tags for html elements like table td tr etc!

heres what I ended up with.

Code:
function process_message_preview($message)
{
    global $vbulletin, $vbphrase, $stylevar, $show;

    require_once(DIR . '/includes/class_bbcode.php');
    $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

    $previewhtml = '';
    if ($previewmessage = $bbcode_parser->parse($message, 'socialmessage', $message['disablesmilies'] ? 0 : 1))
    {
        $previewhtml = $previewmessage;
    }

    return $previewhtml;
}  


$mypage = process_message_preview($vbulletin->userinfo['field65']);

eval('$mypage = "' . fetch_template('user_custompage') . '";');
I created a custom template called "user_custompage" and just dumped the $mypage variable in it and nothing else. Works great.
Reply With Quote
  #6  
Old 04-03-2009, 04:55 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great! :up:
Reply With Quote
  #7  
Old 04-04-2009, 03:31 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had posted something saying I was going to go look at class_bbcode.php. I did, and have changed my code to the following...

Code:
function process_message_preview($message)
{
    global $vbulletin, $vbphrase, $stylevar, $show;

    require_once(DIR . '/includes/class_bbcode.php');
    $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

    $previewhtml = '';
    if ($previewmessage = $bbcode_parser->do_parse($message, $do_html = true, $do_smilies = true, $do_bbcode = true, $do_imgcode = true, $do_nl2br = true, $cachable = false))
    {
        $previewhtml = $previewmessage;
    }

$mypage = process_message_preview($vbulletin->userinfo['field65']);

eval('$mypage = "' . fetch_template('user_custompage') . '";');
Now what I don't understand is why its not allowing me to use <table> and </table> in my profile field.
Here is my profile field code.
PHP Code:
<table>

[
B]Here is my test page[/B]
[
img]https://vborg.vbsupport.ru/external/2009/04/7.gif[/img]

</table
On MEMBERINFO template, I'm able to show my bold text, the google image, but the <table> tags just show up like text, not html. Any Ideas?
Reply With Quote
  #8  
Old 04-04-2009, 04:51 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<table> is html not bbcode. You would have to parse it for html otherwise it will treat the < and > as text characters and turn them into &lt; and $gt; in the page source.
Reply With Quote
  #9  
Old 04-04-2009, 06:20 PM
carcomp carcomp is offline
 
Join Date: Feb 2008
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Risking posting before googling, is there an HTML parse function in vbulletin?
Reply With Quote
  #10  
Old 04-05-2009, 02:10 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Probably. You can look in the API for one (link under Quick Links)
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 12:55 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.04982 seconds
  • Memory Usage 2,272KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete