Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 01-17-2008, 02:49 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just to clarify you are placing this code in a PLUGIN correct? (AdminCP > Plugins and Products > Add New Plugin)

And not a TEMPLATE? (AdminCP > Style Manger....)

You keep saying plugin template its confusing as to what you mean exactly as they are two different things.
Reply With Quote
  #12  
Old 01-17-2008, 02:58 PM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The plugin article said a plugin is a variable that display the contents of another template. I've been putting the code in this second template. Should the code be in the plugin itself? The plugin code is currently
Code:
$eveitapi = fetch_template('eveitapi');
So if I put all the PHP in the plugin itself, I should be able to use the defined variables on any template (since the plugin is in global_start)? When I said plugin template I was referring to the template the plugin calls. When I said display template I was referring to the template that had $eveitapi where I wanted the plugin stuff to display.
Reply With Quote
  #13  
Old 01-17-2008, 03:02 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure what article you were reading but a Plugin is a peice of PHP Code that is excuted at a certain location (the hook location) by vBulletin. You PHP Code must go inside a Plugin.

You can use a Plugin to fetch a template, a template is front-end HTML that is displayed to the user. You can use variables in your template that get their values from the PHP code, but you cannot execute PHP code inside templates.

Think of it like this (this is just a demonstration of how the system works you do not need to use this code at all!):
PHP Code:
// This is just some default vBulletin PHP file

// This is where you launch your api and get your data
eval('YOUR PLUGIN CODE WILL APPEAR HERE');

echo 
"YOUR TEMPLATE CODE WILL BE HERE AND IT IS OUTPUTTED TO THE USER";

// End of the Script 
Reply With Quote
  #14  
Old 01-17-2008, 03:26 PM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried putting the code in a plugin with hook global_start but variables weren't available to the template. When I put the code directly in the php file things work. Are there any security issues with putting the code directly in the php file?
Reply With Quote
  #15  
Old 01-17-2008, 03:51 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template was it? and make sure you checked that the variables actually had some data in them. Also make sure you eval()'d the template like this (if you are using a custom one)

PHP Code:
eval('$somevar = "'fetch_template('your_template') .'";'); 
Then you would place $somevar in a normal vBulletin template and it would display your code there.

I doesn't make much difference if you place your code in Plugins or PHP files, but the plugin system is there so you don't have to mess with Files.
Reply With Quote
  #16  
Old 01-17-2008, 04:23 PM
petteyg359 petteyg359 is offline
 
Join Date: Dec 2007
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The file is 'eveit.php'. The template is 'eveit'. It is working just fine with the API code in the PHP file. The template is called at the very bottom of the PHP file
PHP Code:
eval('print_output("' fetch_template('eveit') . '");'); 
I deleted the second template and tried the code in a plugin instead, but I think it is better in the PHP rather than a global_start plugin, as I only want the API access performed on eveit.php (the rest of the site doesn't make use of the data). Is it possible to make a plugin load only for a specified custom template?
Reply With Quote
  #17  
Old 01-18-2008, 03:54 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If the code you're wanting to put is in your own custom file, by all means, put that code in your file. Plugins are mainly for vBulletin so that when you update, your edits aren't lost.
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 07:52 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.06012 seconds
  • Memory Usage 2,215KB
  • Queries Executed 13 (?)
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
  • (3)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
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete