Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-04-2009, 04:10 PM
Elmer's Avatar
Elmer Elmer is offline
 
Join Date: Aug 2002
Location: Washington DC
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default str replace into forumhome_forumbit_level2_post

I have read the other threads about this but none had helped me.

I have added an option in the editing/creating a forum page. My option variable is $forum[var].
When I place the variable {vb:raw forum.newoption} directly into forumhome_forumbit_level2_post it works, it displays the data.
So I'm trying to do this via plugin with the following code:

PHP Code:
$find '<p class="theclass">';
$insert '{vb:raw forum.newoption}';
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find,$find.$insert $vbulletin->templatecache['forumhome_forumbit_level2_post']); 
The plugin works, but I get the variable outputted, not the data that is storing.

After this, I did try using a template, with the variable in it. Then I registered and rendered the template y used that to str replace.

PHP Code:
$templater =  vB_Template::create('forumhome_mynewoption');
$templater->register('forum'$forum);
$insert $templater->render();
$find '<p class="forumdescription">';

$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find,$find.$insert $vbulletin->templatecache['forumhome_forumbit_level2_post']); 
This works, but outputs the same data for each forum, even if I just inserted some values in my option in only one forum.

I must say that I'm new creating plugins, maybe I'm missing something.
Reply With Quote
  #2  
Old 12-04-2009, 04:15 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
{vb:raw forum.newoption}
is for templates not plugins.


It would be more like the following:
Code:
$find = '<p class="theclass">';
$insert = $forum[var];
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find,$find.$insert , $vbulletin->templatecache['forumhome_forumbit_level2_post']);
Reply With Quote
  #3  
Old 12-04-2009, 04:58 PM
Elmer's Avatar
Elmer Elmer is offline
 
Join Date: Aug 2002
Location: Washington DC
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That works as my template approach.
The variable ouput get repeated into the next forum, even is the next has its own value. The second forum shows its value, but the value from the previous forum.

I'm looking into the vBulletin files to see how they do that, I'm not good at this but i'm learning
Reply With Quote
  #4  
Old 12-04-2009, 05:08 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can you paste more of your code

Did you set your own variable for $forum or $forum[newoption]

I am not totally understanding what it is you want to do. I think you want to grab the postid for each post.

add this in your code towards the bottom:
Code:
var_dump($forum[newoption]);
Tell me the output that shows above the header.
Reply With Quote
  #5  
Old 12-04-2009, 05:16 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You probably need to zero it out prior to setting it. That way, if you don't set it for that particular forum, it won't show the previous setting.
Reply With Quote
  #6  
Old 12-04-2009, 05:35 PM
Elmer's Avatar
Elmer Elmer is offline
 
Join Date: Aug 2002
Location: Washington DC
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$forum[newoption] is from the options when editing a forum. I've added a new option there:

hook: forumadmin_edit_form
PHP Code:
print_table_header($vbphrase['teh_forumicon']);
print_input_row($vbphrase['teh_forumicon_desc'], 'forum[iconlocation]'$forum['iconlocation']); 
I then validated the data:
hook: forumdata_start
PHP Code:
$this->validfields['iconlocation'] = array(TYPE_STRREQ_NO); 
I also added a iconlocation field to the forum table in my database. That part works as spected. It saves the data.

Now using the variable directly into my template it works as spected too: $forum[iconlocation] as {vb:raw forum.iconlocation}

The problem is trying to insert that variable using a plugin:

PHP Code:
$find '<p class="forumdescription">';
$insert '<img src="'.$forum[iconlocation].'" alt="'.$forum[title].'" />';
$vbulletin->templatecache['forumhome_forumbit_level2_post'] = str_replace($find,$find.$insert$vbulletin->templatecache['forumhome_forumbit_level2_post']);
var_dump($forum[iconlocation]); 
I've attaced a screenshot so you can see what i'm talking about.

Also the output for var_dump($forum[iconlocation]); is
Code:
string(31) "images/misc/skype_voicemail.gif" string(32) "images/misc/skype_addcontact.gif" string(0) ""
Attached Images
File Type: png 12-4-2009 2-32-07 PM.png (17.2 KB, 0 views)
Reply With Quote
  #7  
Old 12-04-2009, 05:53 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this:
Code:
$insert = '<img src="$forum[iconlocation]" alt="$forum[title]" />';
you can remove this:
Code:
var_dump($forum[iconlocation]);
Reply With Quote
  #8  
Old 12-04-2009, 06:42 PM
Elmer's Avatar
Elmer Elmer is offline
 
Join Date: Aug 2002
Location: Washington DC
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, that isn't the problem. If I use that I get printed the variable names, not the data.

Thank you for your help, I'm going to release the plugin as it is, and ask the user to make a template edit to insert the html code. I can't make it work.
Reply With Quote
  #9  
Old 12-04-2009, 09:27 PM
BBR-APBT's Avatar
BBR-APBT BBR-APBT is offline
 
Join Date: Feb 2009
Location: Maryland
Posts: 946
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When you release it I will take a look and see if I cant make it work the way you want.
Reply With Quote
  #10  
Old 12-04-2009, 09:52 PM
Elmer's Avatar
Elmer Elmer is offline
 
Join Date: Aug 2002
Location: Washington DC
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's been released. Actually without automatic template edit the product is useless since the same icon can be added into the forum description without having to modify templates

https://vborg.vbsupport.ru/showthread.php?p=1925448
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.15671 seconds
  • Memory Usage 2,290KB
  • Queries Executed 12 (?)
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_code
  • (5)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
  • (1)postbit_attachment
  • (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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete