vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Plugin Coding Question: Function Syntax (https://vborg.vbsupport.ru/showthread.php?t=111579)

ThePimp 03-28-2006 03:11 PM

Plugin Coding Question: Function Syntax
 
What is the proper syntax for calling a function in a plugin?

Here's my issue, I'm including a file that defines a function called newsfeed().

Here's my plugin code currently: (HOOK: global_complete)
Code:

ob_start();
include('magpierss/rss_parse.inc');
newsfeed("http://rss.cnn.com/rss/cnn_topstories.rss",5,"CNN HEADLINES");
$cnn=ob_get_contents();
ob_end_clean();

This is supposed to output an rss feed wherever I call $cnn.

However, what happens, is that the feed shows up at the very top of the page, not where I put the $cnn call.

Is there something I'm not doing properly?

Any help is appreciated.

Thanks in advance.

Krofh 03-28-2006 04:15 PM

It could likely not be accessing the variable $cnn correctly... when you have a variable inside a function, you have to make it global, which I think works like so:

Code:

global $cnn; // define it outside of the function

function myfunction() {
global $cnn; // call it from outside so it knows
dostufff();
$cnn = something();
}

echo "$cnn";

Someone can correct me on this, because I'm not great with global variables, but I'm pretty sure that this is how they work.

ThePimp 03-28-2006 04:51 PM

Quote:

Originally Posted by Krofh
It could likely not be accessing the variable $cnn correctly... when you have a variable inside a function, you have to make it global, which I think works like so:

Code:

global $cnn; // define it outside of the function

function myfunction() {
global $cnn; // call it from outside so it knows
dostufff();
$cnn = something();
}

echo "$cnn";

Someone can correct me on this, because I'm not great with global variables, but I'm pretty sure that this is how they work.

The function is defined outside of the plugin system. I have to include the file in order to access the newsfeed() function.

So, really, all the plugin needs to do is:
include("functionfile.php");

newsfeed()

And that's it.

I got it to work, it just doesn't show up in the right place.

bump


All times are GMT. The time now is 07:47 AM.

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.00937 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete