Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 06-05-2003, 10:13 PM
Serge's Avatar
Serge Serge is offline
 
Join Date: Jan 2002
Location: The Matrix
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Template help

Ok i'm having a bit of a problem. I tried to make my own template function to call my templates for my website where here is what I got:

The gettemplate function:
PHP Code:
/////////////////// Start Gettemplate //////////////////
function gettemplate($templatename) {
//Get template from database
$template mysql_query("SELECT template FROM template WHERE title = '".addslashes($templatename)."'") or
        die (
mysql_error());
$template_body mysql_fetch_array($template);
return 
str_replace("\\'""'"addslashes($template_body['template']));

The call for the template inside a webpage:

PHP Code:
eval("\$header = \"".gettemplate('main_head')."\";"); 
I have that exact thing in index.php on my site but when I call up index.php it shows nothing.

Could anyone help me on why when I call the templates they arn't showing up?
Reply With Quote
  #2  
Old 06-05-2003, 11:16 PM
Serge's Avatar
Serge Serge is offline
 
Join Date: Jan 2002
Location: The Matrix
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I figuare I would post an update on what I have done so far. I have ran a small test script that would insure that the templates where there and it worked and it did exactly what I wanted it to do. So I guess my problem is the function which is above.
Reply With Quote
  #3  
Old 06-06-2003, 03:02 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This should work fine:

PHP Code:
function findtemplate($templatename) {

    
$gettemp mysql_query("SELECT template FROM template WHERE title='".addslashes($templatename)."' LIMIT 1") or die(mysql_error());

    
$tmp mysql_fetch_array($gettemp);

    
$tmp addslashes($tmp);
    
$tmp str_replace("\\'","'",$tmp);

  return 
$tmp;

Store as variable:
PHP Code:
eval("\$template= \"".findtemplate('homepage')."\";"); 
Or output directly:
PHP Code:
echo findtemplate('homepage'); 
Reply With Quote
  #4  
Old 06-06-2003, 03:33 AM
Serge's Avatar
Serge Serge is offline
 
Join Date: Jan 2002
Location: The Matrix
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Either echoing it our directly or the other way worked and I can't seem to find out why? Do I have php setup wrong maybe? Could someone please help.
Reply With Quote
  #5  
Old 06-06-2003, 02:54 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't get it, what are you trying to figure out? So please clarify.
You have a solution to your template problem, what does it have to do with the setup of PHP?
Reply With Quote
  #6  
Old 06-06-2003, 05:58 PM
Serge's Avatar
Serge Serge is offline
 
Join Date: Jan 2002
Location: The Matrix
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The solution you gave didn't work. So I need another solution. I remeber one time I had a switch statement that didn't work because register_globals was turned off so I thought that maybe this or someone other set-up variable was causing my problems but I think I got an answer over at sitepoint.

Thanks anyways!
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 11:53 AM.


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.04034 seconds
  • Memory Usage 2,216KB
  • 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
  • (5)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