Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 06-23-2008, 01:11 AM
StephenKay StephenKay is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help with including php files using image vars

I have studied the tutorial section on how to included php files.

I want to include my header template as a file on my server, instead of pasting it into the area in the style manager.

So I have created a plug-in attached to the global_start hook:

PHP Code:
ob_start();
include(
'kl_templates/header.php');
$inc_tpl_header ob_get_contents();
ob_end_clean(); 
In the style manager, in the header template, is:

PHP Code:
$inc_tpl_header 
So far, so good. It works somewhat - the header file (on my server as /forum/kl_templates/header.php is indeed included.) The problem is that there are images in the header which are referenced as (example):

HTML Code:
<img src="$stylevar[imgdir_misc]/nav_welcome.gif" width="251" height="29" alt="" />
These images cannot be located. It seems that this variable is not available?

Also, there are some php variables in the header template, that are just getting printed out, instead of the actual php code.

Do I need to put an eval() somewhere in the above code? Kind of lost on this... thanks.

--------------- Added [DATE]1214187596[/DATE] at [TIME]1214187596[/TIME] ---------------

Actually, looking at the HTML source shows that the php in the header is not being executed. the URL of the images still show up as $stylevar[...], so obviously I need to be doing something different to get the php in the header.php file to actually execute, but what?
Reply With Quote
  #2  
Old 06-23-2008, 02:04 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this in your plugin.
PHP Code:
ob_start();
include(
'kl_templates/header.php');
$inc_tpl_header ob_get_contents();
eval(
'$inc_tpl_header = "' $inc_tpl_header '";');
ob_end_clean(); 
Then use the same code in your template.
Reply With Quote
  #3  
Old 06-23-2008, 03:53 AM
StephenKay StephenKay is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply - but I tried it and it doesn't get any different result. The php is still not executing. Here is a slightly simplified version of the kl_templates/header.php file:

HTML Code:
<div id="back-gradient">
<!-- set below for skin width-->
<table id="main-table" width="970px" border="0" align="center" cellpadding="0" cellspacing="0" style="padding-bottom:15px">
    <tr>
        <td width="100%" align="left" valign="top">
        
            <!-- begin logo and graphic -->
            <div id="hdr">
                <table id="logo" cellspacing="0" cellpadding="0" align="center">
                    <tr>
                        <td rowspan="2"><img src="iSkin_Black/misc/klf_logo.jpg" alt="Karma-Lab Forums" height="111" width="268" /></td>
                        <td><img src="iSkin_Black/misc/klf_graphic.jpg" alt="KARMA Technology and the products incorporating it" height="86" width="685" /></td>
                    </tr>
                </table>
            </div>

            <div id="brd_outer">
                <div id="brd_in">
                    <!-- begin top black nav bar -->
                    <div id="nav_back">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr valign="top">
                                <td width="172" height="29" align="left"><img src="$stylevar[imgdir_misc]/nav_ls.gif" width="70" height="29" alt="" /></td>
                                <td align="center"><img src="$stylevar[imgdir_misc]/nav_welcome.gif" width="251" height="29" alt="" /></td>
                                <td width="172" height="29" align="right">
                                    <table width="182" border="0" align="center" cellpadding="0" cellspacing="0">
                                    <!-- begin navigation buttons table -->
                                        <tr>
                                            <if condition="$show['registerbutton']">
                                            <td width="87" height="29"><a href="register.php$session[sessionurl_q]" rel="nofollow"><img id="nav_reg" src="$stylevar[imgdir_misc]/nav_reg.gif" width="87" height="29" alt="" /></a></td>
                                            <else />
                                            <td width="87" height="29" id="usercptools"><a href="$show[nojs_link]#usercptools" accesskey="3"><img id="nav_menu" src="$stylevar[imgdir_misc]/nav_menu.gif" width="87" height="29" alt="" /></a>
                                                    <script type="text/javascript"> vbmenu_register("usercptools", 1); </script>
                                            </td>
                                            </if>
                                            <td width="75" height="29"  id="navbar_search"><a href="search.php$session[sessionurl_q]" accesskey="4" rel="nofollow"><img id="nav_search" src="$stylevar[imgdir_misc]/nav_search.gif" width="75" height="29" alt="" /></a>
                                            <if condition="$show['quicksearch']">
                                                    <script type="text/javascript"> vbmenu_register("navbar_search" ,1); </script></if>
                                            </td>
                                                <!-- End navigation buttons table -->
                                            <td width="20" height="29" align="right" valign="top"><img src="$stylevar[imgdir_misc]/nav_rs_end.gif" width="20" height="29" alt="" /></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <!-- content table -->
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td>

                    $spacer_open
                    
                    $_phpinclude_output
                    $ad_location[ad_header_end]
Reply With Quote
  #4  
Old 06-23-2008, 06:27 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
ob_start();
include(
'kl_templates/header.php');
$inc_tpl_header ob_get_contents();
ob_end_clean();
eval(
'$inc_tpl_header = "' addslashes($inc_tpl_header) . '";'); 
Reply With Quote
  #5  
Old 06-23-2008, 08:06 AM
StephenKay StephenKay is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for you reply, but again (sadly), it did not work. Same result. Very strange, I agree. I also believe an eval() is needed, but so far, it is not working....
Reply With Quote
  #6  
Old 06-23-2008, 12:35 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does "$stylevar" actually appear when you view the source? Try:
PHP Code:
ob_start();
include(
'kl_templates/header.php');
$inc_tpl_header ob_get_contents();
ob_end_clean();
eval(
'$inc_tpl_header = "' $inc_tpl_header '";'); 
Reply With Quote
  #7  
Old 06-23-2008, 02:31 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try the global_setup_complete hook and see if you get any errors or anything.
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 02:36 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.05812 seconds
  • Memory Usage 2,244KB
  • Queries Executed 11 (?)
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_html
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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