Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2008, 06:38 PM
DHDesign DHDesign is offline
 
Join Date: Sep 2007
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Include PHP in Template and call Function

so i get how to include a PHP file in my template using the Plug system, but then the vBulletin manual says that I need to put the contents of the file into a variable like $includedphp and when I want to output its contents, I just call $includedphp from the template.....BUT

my include file is just a bunch of functions and I want the template to be able to access the functions (like footers, headers, stuff generated from the DB)

so in the template i need:

<div id="footer">
<? display_footer(): ?>
</div>

...i need somehting like that work.

any thoughts? thanks!
Reply With Quote
  #2  
Old 03-05-2008, 06:44 PM
WhaLberg's Avatar
WhaLberg WhaLberg is offline
 
Join Date: Nov 2006
Location: Dersaadet
Posts: 569
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try $myvar = display_footer(); and put $myvar to the template.
Reply With Quote
  #3  
Old 03-05-2008, 06:51 PM
DHDesign DHDesign is offline
 
Join Date: Sep 2007
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so put $myvar = display_footer(); in the hook?
Code:
ob_start();
  include('path/to/file/cms.php');
  $includedphp = ob_get_contents();
  $myvar = display_footer();
ob_end_clean();
cause i tried that above, and nothing...a little more detail possibly? thanks for the response though!
Reply With Quote
  #4  
Old 03-05-2008, 08:13 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:

PHP Code:
ob_start();
include(
'path/to/file/cms.php');
display_footer();
$myvar ob_get_contents();
ob_end_clean(); 
Reply With Quote
  #5  
Old 03-05-2008, 08:58 PM
WhaLberg's Avatar
WhaLberg WhaLberg is offline
 
Join Date: Nov 2006
Location: Dersaadet
Posts: 569
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If your function is echoing or something, you can use the codes below:

PHP Code:
function display_footer()
{
    
$footer "info here";
    return 
$footer;
}

// and in the other file
$myvar display_footer(); 
Can you show us how you have the display_footer() function?
Reply With Quote
  #6  
Old 03-05-2008, 09:23 PM
DHDesign DHDesign is offline
 
Join Date: Sep 2007
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, its not only the display_footer() function i need, but to answer your question:

Code:
function display_footer() {
  $footer = mysql_query("SELECT Footer_Text FROM footer_table WHERE F_ID = 1 LIMIT 1");
  $footerrow = mysql_fetch_array($footer);
  print $footerrow['Footer_Text'];
}
--------------- Added [DATE]1204764706[/DATE] at [TIME]1204764706[/TIME] ---------------

@Opserty: that worked, but what if my include file has more than one function in it and i want to display different things in different areas of the template? say i have display_footer(), display_navigation(), display_header()....each now needs a variable to display in different parts...do i just create three separate hooks?

@WhaLberg: thanks for ur help and responses...the only issue with ur method is that id have to change my functions to return values...these functions are also used on other nonvbulletin pages, so changing them affects other pages too
Reply With Quote
Reply


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:13 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03633 seconds
  • Memory Usage 2,210KB
  • 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
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete