vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   getting a $name evaluated (https://vborg.vbsupport.ru/showthread.php?t=37518)

jjj0923 04-16-2002 11:10 PM

getting a $name evaluated
 
I'm somewhat confused.

I've developed some additional code in index.php

PHP Code:

$fbmenu='';
if (
$lastphoto $userlastvisit) { 
    eval(
"\$fbmenu = \"".gettemplate('fb_menu')."\";"); 
} else {  
    eval(
"\$fbmenu = \"".gettemplate('fb_menu1')."\";"); 



I've added fb_menu and fb_menu1 to my templates and added $fbmenu to the code in the 'Header' template but it won't evaluate and display the html contained in the fb_menu or fb_menu1 template.
My php code is down near the bottom of index.php and it outside of any conditional clauses and I know it's working fine because I did lots of testing before implementing it.

Does Vbulletin NOT evaluate code in templates (such as header)?
I've done this before but and added $variables associated with templates in index.php but the results of that code ($'name') was placed in forum_home

this one really has me stumped.... I know my php code is working, but vb doesn't want to associate $fbmenu with my template... any ideas???

thanks in advance.

- jeff

Admin 04-17-2002 08:11 AM

You need to place that code in global.php before $header is eval()'ed.

jjj0923 04-17-2002 10:26 AM

firefly, I'm almost there, byt placing the code right before loading the header template breaks the following:

1) logged out users cannot log-in
2) new users that have just registered cannot log in.

other than that; the code (for registered users) who have not logged out works great.

here's my code; do you have any ideas?

PHP Code:

// begin hack for testing when last photo was posted compared to last date user visited site

$fbmenu='';
eval(
"\$fbmenu = \"".gettemplate('fb_menu')."\";");

echo 
$userlastvisit;

$user=$DB_site->query_first("SELECT * FROM user WHERE userid=$bbuserinfo[userid]");
$username=$user[username];
$userlastvisit=$user['lastvisit'];

$db1name "PhotoPost_info";          
$link_id mysql_connect($servername$dbusername$dbpassword);
mysql_select_db($db1name$link_id);
$result mysql_query("SELECT max(photos.date) as lastphoto from photos");
while(
$query_data mysql_fetch_row($result)) { $lastphoto $query_data[0]; }
mysql_select_db($dbname);

if (
$lastphoto $userlastvisit) {
        eval(
"\$fbmenu = \"".gettemplate('fb_menu')."\";");
    } else {
        eval(
"\$fbmenu = \"".gettemplate('fb_menu1')."\";");
    }

// end hack 


Admin 04-17-2002 04:23 PM

You use $username in your code which breaks the log-in form. Just use $bbuserinfo[username] and $bbuserinfo[lastvisit], you don't need another query for that. And you also don't need to create another database connection, just use the current opened one.

jjj0923 04-17-2002 05:18 PM

oh yea...
much nicer...
I also changed the perl code in Photo Post to simply write a 10 character text file with the most recent post date and used an fopen in global.php to read it....

much nicer, much faster and working great!

thank!

- jeff

Admin 04-17-2002 05:53 PM

No problems. :)


All times are GMT. The time now is 09:25 PM.

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.01009 seconds
  • Memory Usage 1,731KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete