vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Getting include statements to work in the forum templates? (https://vborg.vbsupport.ru/showthread.php?t=43254)

futureal 09-13-2002 10:22 PM

You could put something like $stuff = something; in global.php and then use $stuff in a template anywhere on the site.

Gutspiller 09-13-2002 10:26 PM

Quote:

Originally posted by futureal
You could put something like $stuff = something; in global.php and then use $stuff in a template anywhere on the site.
Is that the actual code?

so if I put
PHP Code:

$shortnews = include("shortnews.php"); 

then in my templates whenever I put in $shortnews it would call the shortnews.php file?

I just wanted to make sure that was the exact code or if you were putting more emphasis on "like"?

This is going to be KICK ASS! :D

futureal 09-14-2002 02:19 AM

Sort of, but not exactly.

In your global.php file, you need to add a line like this:

PHP Code:

$something = eval("include(\"somefile.php\");"); 

The eval() function evaluates a line of code "on-demand" rather than every time the script runs. In other words, if you did it your way (without eval) then it would just display the contents of the included PHP file at the top of every page -- I don't believe include() returns a value.

Anyway, then in your templates, wherever you add $something, you will get the contents of the PHP file.

This is essentially the third option that Logician gave:

Quote:

3- Add you code to global.php. It also runs everytime any vb scripts runs, just like phpinclude template.Therefore you can try to add either the include statement or the entire code to global.php as well..
And yes, it works; I just tested it on one of my sites. Have fun.

Gutspiller 09-14-2002 07:39 AM

That seems to do the same thing. I didn't even call it in the template. As soon as I put it in the global file it called it and put it above the header.

Anything else? :(

futureal 09-14-2002 04:29 PM

OK, for some reason I was thinking that your included file would be performing some sort of function rather than just outputting data.

I thought about it some more, and I'm not sure how you would get the output "on demand" as you suggest, without adding it to the vBulletin code -- assuming that the PHP file you want to include echoes something back.

Why not just edit the files so that they "store" their output in a variable, then put the file in the global.php as I suggested (or the phpinclude template as Logician suggested) and then just use that variable where you need the output?

I can't think of any other way to do it. I think that to achieve what you're trying to do, you're going to need to work with the code one way or another.

Gutspiller 09-14-2002 04:35 PM

Quote:

Originally posted by futureal
OK, for some reason I was thinking that your included file would be performing some sort of function rather than just outputting data.

I thought about it some more, and I'm not sure how you would get the output "on demand" as you suggest, without adding it to the vBulletin code -- assuming that the PHP file you want to include echoes something back.

Why not just edit the files so that they "store" their output in a variable, then put the file in the global.php as I suggested (or the phpinclude template as Logician suggested) and then just use that variable where you need the output?

I can't think of any other way to do it. I think that to achieve what you're trying to do, you're going to need to work with the code one way or another.

Can one of you help me with doing that? I'm a noob when it comes to rewriting the code, etc. Can anybody give me instructions on what I need to do inorder to get this to work? :ermm:

Gutspiller 01-25-2003 06:42 PM

bump!


All times are GMT. The time now is 08:22 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.01040 seconds
  • Memory Usage 1,739KB
  • 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
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete