Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 09-05-2010, 07:34 AM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Plugin Help Pretty-Please

Thank-you to anyone who reads this with a view to helping me. I'm stuck

I'm trying to get a home-made addon that I used on my old 3.6.8 board to work on my 4.0.6 board. Everything works except one plugin that calculates the values of table rows to show total debits ($totaldebits), total credits ($totalcredits) and overall total ($totaltotal).

Values are entered in admincp fields and display on a table. Negative values entered in the admincp fields display within the Debit column & Balance column whereas positive values display within the Credit column & Balance column. I use the following to achieve that:
Sample of table ROW code:
PHP Code:
  </td>
    <
td class="alt1"><vb:if condition="$vboptions[vcaccounts_Row_1_Value]<0">{vb:raw vboptions.vcaccounts_Row_1_Value}<vb:else /> </vb:if></td>
    <
td class="alt1"><vb:if condition="$vboptions[vcaccounts_Row_1_Value]>0">{vb:raw vboptions.vcaccounts_Row_1_Value}<vb:else /> </vb:if></td>
    <
td class="alt1">{vb:raw vboptions.vcaccounts_Row_1_Value}</td>
  </
tr
Admincp Fields:


Table Result:


The old plugin (for 3.6.8) automatically calculated the totals of the Debit, Credit and Balance columns and looks like this:
PHP Code:
if (THIS_SCRIPT=='Accounts') {
$totaltotal $vbulletin->options['don_field1']+$vbulletin->options['don_field2']+$vbulletin->options['don_field3']+$vbulletin->options['don_field4']+$vbulletin->options['don_field5']+$vbulletin->options['don_field6']+$vbulletin->options['don_field7']+$vbulletin->options['don_field8']+$vbulletin->options['don_field9']+$vbulletin->options['don_field10'];
$totaltotal round($totaltotal2);
$totaldebits 0;
if(
$vbulletin->options['don_field1']<0) {
$totaldebits += $vbulletin->options['don_field1']; } else {
$totalcredits += $vbulletin->options['don_field1'];
}
if(
$vbulletin->options['don_field2']<0) {
$totaldebits += $vbulletin->options['don_field2']; } else {
$totalcredits += $vbulletin->options['don_field2'];
}
if(
$vbulletin->options['don_field3']<0) {
$totaldebits += $vbulletin->options['don_field3']; } else {
$totalcredits += $vbulletin->options['don_field3'];
}
if(
$vbulletin->options['don_field4']<0) {
$totaldebits += $vbulletin->options['don_field4']; } else {
$totalcredits += $vbulletin->options['don_field4'];
}
if(
$vbulletin->options['don_field5']<0) {
$totaldebits += $vbulletin->options['don_field5']; } else {
$totalcredits += $vbulletin->options['don_field5'];
}
if(
$vbulletin->options['don_field6']<0) {
$totaldebits += $vbulletin->options['don_field6']; } else {
$totalcredits += $vbulletin->options['don_field6'];
}
if(
$vbulletin->options['don_field7']<0) {
$totaldebits += $vbulletin->options['don_field7']; } else {
$totalcredits += $vbulletin->options['don_field7'];
}
if(
$vbulletin->options['don_field8']<0) {
$totaldebits += $vbulletin->options['don_field8']; } else {
$totalcredits += $vbulletin->options['don_field8'];
}
if(
$vbulletin->options['don_field9']<0) {
$totaldebits += $vbulletin->options['don_field9']; } else {
$totalcredits += $vbulletin->options['don_field9'];
}
if(
$vbulletin->options['don_field10']<0) {
$totaldebits += $vbulletin->options['don_field10']; } else {
$totalcredits += $vbulletin->options['don_field10'];
} } 
The new plugin for 4.0.6 currently looks like this and doesn't seem to work: (currently=many edits/trials)
PHP Code:
       <plugin active="1" product="vbulletin" executionorder="40">
        <
title><![CDATA[VC_Accounts Totals]]></title>
        <
hookname>misc_start</hookname>
        <
phpcode>if (THIS_SCRIPT=='vcaccounts') {
$totaltotal $vbulletin->options['vcaccounts_Row_1_Value']+$vbulletin->options['vcaccounts_Row_2_Value']+$vbulletin->options['vcaccounts_Row_3_Value']+$vbulletin->options['vcaccounts_Row_4_Value']+$vbulletin->options['vcaccounts_Row_5_Value']+$vbulletin->options['vcaccounts_Row_6_Value']+$vbulletin->options['vcaccounts_Row_7_Value']+$vbulletin->options['vcaccounts_Row_8_Value'];
$totaltotal round($totaltotal2);
$totaldebits 0;
if(
$vbulletin->options['vcaccounts_Row_1_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_1_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_1_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_2_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_2_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_2_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_3_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_3_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_3_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_4_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_4_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_4_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_5_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_5_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_5_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_6_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_6_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_6_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_7_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_7_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_7_Value'];
}
if(
$vbulletin->options['vcaccounts_Row_8_Value']&lt;0) {
$totaldebits += $vbulletin->options['vcaccounts_Row_8_Value']; } else {
$totalcredits += $vbulletin->options['vcaccounts_Row_8_Value'];
} }
        </
phpcode>
    </
plugin
I've registered what I think should be registered:
Code:
    $templater->register('totaldebits', $totaldebits);
    $templater->register('totalcredits', $totalcredits);
    $templater->register('totaltotal', $totaltotal);
The Totals Row of my table looks like this:
PHP Code:
  <tr>
    <
th class="alt3" style="width:25%">{vb:rawphrase vcaccounts_table_totals}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totaldebits}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totalcredits}</th>
    <
th class="alt3" style="width:15%">{vb:var vboptions.vcaccounts_currency_symbol}{vb:raw totaltotal}</th>
  </
tr
Note: It's all in an .xml document. I don't know if that matters but thought I'd mention it just in case. It all installs okay except for that plugin refusing to work for me.

I've tried using different Hook Locations but with no success. I'm guessing there is something wrong with my 4.0.6 plugin and was hoping someone might be able to spot something obvious and push me in the right direction.
Reply With Quote
  #2  
Old 09-05-2010, 02:30 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is more to registering a variable than just what you wrote above. That one part is correct for that part. But, we'd need to see the whole thing in order to see that you did it correctly.
Reply With Quote
  #3  
Old 09-05-2010, 06:30 PM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
There is more to registering a variable than just what you wrote above. That one part is correct for that part. But, we'd need to see the whole thing in order to see that you did it correctly.
Hi Lynne and thanks for your attention .

At present the list of variables are all bunched up together on my .xml document between </templates> and <plugins>.
PHP Code:
</templates>
    
$templater->register('vcaccounts_table_title'$vcaccounts_table_title);
    
$templater->register('vcaccounts_table_title'$vcaccounts_table_subtitle);
    
$templater->register('vcaccounts_currency'$vcaccounts_currency);
    
$templater->register('vcaccounts_date'$vcaccounts_date);
    
$templater->register('vcaccounts_donthanks'$vcaccounts_donthanks);
    
$templater->register('vcaccounts_donators'$vcaccounts_donators);
    
$templater->register('vcaccounts_Row_1_Value'$vcaccounts_Row_1_Value);
    
$templater->register('vcaccounts_Row_2_Value'$vcaccounts_Row_2_Value);
    
$templater->register('vcaccounts_Row_3_Value'$vcaccounts_Row_3_Value);
    
$templater->register('vcaccounts_Row_4_Value'$vcaccounts_Row_4_Value);
    
$templater->register('vcaccounts_Row_5_Value'$vcaccounts_Row_5_Value);
    
$templater->register('vcaccounts_Row_6_Value'$vcaccounts_Row_6_Value);
    
$templater->register('vcaccounts_Row_7_Value'$vcaccounts_Row_7_Value);
    
$templater->register('vcaccounts_Row_8_Value'$vcaccounts_Row_8_Value);
    
$templater->register('totaldebits'$totaldebits);
    
$templater->register('totalcredits'$totalcredits);
    
$templater->register('totaltotal'$totaltotal);
    
print_output($templater->render());
  <
plugins
I've experimented with placing them at the bottom of the main template, within a plugin and even at the bottom of the .php file. Everything else seems to function properly except those 3 $totals or/and the associated plugin.

[S]I've attached the .xml and .php files in case that might assist with spotting what I've done wrong.[/S] Removed attachment.
Reply With Quote
  #4  
Old 09-05-2010, 08:41 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That shouldn't be all either. Here are the basic steps - create the template, register the variables, render the template:
PHP Code:
$newTemplate vB_Template::create('someTemplate');
    
$newTemplate->register('variable1'$somearray);
    
$newTemplate->register('variable2'$variabletwo);
$newTemplate->render(); 
You are missing at least the first step.
Reply With Quote
  #5  
Old 09-05-2010, 10:53 PM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks very much indeed Lynne. The plugin now calculates my table rows as it should. Awesome!
Now I've just got to reinstall my test board after experimenting to find the best Hook for that plugin and turning my entire board white hehehe.
Reply With Quote
  #6  
Old 09-09-2010, 09:12 AM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I thought I'd post here because my question relates to this same project. I hope that is okay.

I've 99.9% completed what I wanted to achieve. The only remaining issue that I'm unsure of how to fix is:
- How do I enable the parsing of either BBCode or HTML that is entered in to a text field in the AdminCP and outputted to a table cell in my custom php page?





I didn't do anything special with my 3.6.8 version to be able to achieve parsing HTML in the same circumstances (although BBCode didn't work there):

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

Look at the API (in Quick Links) for functions that deal with html and bbcode. I'm sure you'll find it in there.
Reply With Quote
  #8  
Old 09-10-2010, 05:38 PM
midnz's Avatar
midnz midnz is offline
 
Join Date: Jul 2010
Location: New Zealand
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Look at the API (in Quick Links) for functions that deal with html and bbcode. I'm sure you'll find it in there.
Thanks again Lynne . I found the problem and resolved it. I had typed {vb:var vboptions..... instead of {vb:raw vboptions.... .

100% working now
THE END
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 11:14 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.04628 seconds
  • Memory Usage 2,321KB
  • 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
  • (1)bbcode_code
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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