miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | 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
Registered
#1 | Posted: 24 Apr 2005 22:18 
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:50 
function hello()
{
return 'Hello world!';
}
$hello=hello();

then insert {$hello} in a template.

Author hugh
Registered
#3 | Posted: 25 Apr 2005 13:15 
Thanks, Team.

Author hugh
Registered
#4 | Posted: 4 May 2005 14:59 | Edited by: hugh 
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
Registered
#5 | Posted: 4 May 2005 20:43 
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:48 
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
Registered
#7 | Posted: 30 Aug 2005 17:46 | Edited by: Digibluez 
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:55 
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 Top

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

 Short link for this topic:

 ?
You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB