miniBB ®

miniBB

®
Support Forums
  
 · Start · Sign in · Register · Search · Statistics · File Bank · Manual ·
Master Class miniBB Support Forums / Master Class /  
 

Getting value from a plugin function, incl. those based on the miniBB's pre-defined variables

 
Author hugh
Partaker
#1 · Posted: 24 Apr 2005 22:18Reply Quote
Say I had a simple function I wanted to use as a plugin eg,

function hello()
{
return 'Hello world!';
}

and I wanted to call it from a template with the variable {$hello} (or something).

How would I do that in MiniBB 1.7?

Thanks

Author Team
8-)
#2 · Posted: 25 Apr 2005 11:50Reply Quote
function hello()
{
return 'Hello world!';
}
$hello=hello();

then insert {$hello} in a template.

Author hugh
Partaker
#3 · Posted: 25 Apr 2005 13:15Reply Quote
Thanks, Team.

Author hugh
Partaker
#4 · Posted: 4 May 2005 14:59Reply Quote
Hi Team

How can I pass to a function on the plugins page the final value of $anchor from bb_func_vthread?

Say I had this plugin function:

function hello($number_of_messages)
{
if ($number_of_messages >= 6) {
return 'Hello world!';
}
}
$hello = hello($anchor);


How do I get the $anchor value into it?

Thanks if you can help (miniBB 1.7).

Author hugh
Partaker
#5 · Posted: 4 May 2005 20:43Reply Quote
OK, I've done it. I put $hello = hello($anchor); under $anchor++; in bb_func_vthread. Is that OK?

Author Team
8-)
#6 · Posted: 5 May 2005 10:48Reply Quote
If it works, it is ok :-)

Non-destructively you can use parseMessage() function of bb_plugins, and include calling of your own function there. Vthread script is calling this function each time it loads and parses the certain message. So $GLOBALS['anchor'] will most likely be available there.

Example:

function hello($num){
return $num*2;
}

function parseMessage(){

$h=hello($GLOBALS['anchor']
);
if($h>6) $GLOBALS['anchorMark']='Good';

}
then paste {$anchorMark} under main_posts_cell.html

Author Digibluez
Partaker
#7 · Posted: 30 Aug 2005 17:46Reply Quote
I liked to make a new function,i could do what i want in javascript,but i dont like it.
So if will it do if i put the code in the bb_functions file or do i have to make a new _func file for this.I want ot call it from a template,like main_header.html.If its too hard ot do,tell i skip it.
It's a random quote displayer.
include_once"$root/inc/random.php"; //main script
$filename = "$root/db/quotes.db";//database
$lines = file($filename);
$numQuotes = count ($lines);
$ranNum = rand(1, $numQuotes);
$line = $lines[$ranNum-1];
$element = explode("::",$line);
$theQuote = $element[0];
$theRef = $element[1];
$theLink = $element[2];
$output = outputTable($theQuote, $theRef, $theLink);
echo $output;

random.php

<?php function outputLine($theQuote, $theRef, $theLink){?>
<?php echo $theQuote; ?> - <a href="<?php echo $theLink; ?>" target="_blank"><?php echo $theRef; ?></a>
<?php }?><?php function outputTable($theQuote, $theRef, $theLink){?>
<a href="<?php echo $theLink; ?>" target="_blank"><?php echo $theRef; ?></a><br/><?php echo $theQuote; ?></a>
<?php }?>

Author Team
8-)
#8 · Posted: 30 Aug 2005 17:55Reply Quote
Include this function in bb_plugins.php (as it is the main purpose of it), but do not echo $output - just store the value in $output and then put in main_header.html: {$output} in the desired place.

Master Class miniBB Support Forums / Master Class /
 Getting value from a plugin function, incl. those based on the miniBB's pre-defined variables
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message

BB code for the Bold StyleBB code for the Italic StyleBB Code for the PictureBB code for the URLUpload a File

  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Proceed with the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.