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 08-02-2002, 03:23 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I set variables?

Simple question, but elusive to me. How would I define a new variable to be used in a template.

Say I wanted to use $aaron and have a new bit that would display "Aaron is AwesomE!" wherever I put that in my templates.

In a similar vein, what if I wanted to use some PHP if/else to determine if a variable is set and if it is display it and if it is not, do not. An example of this would be in the postbit of my forum http://forums.livetheworship.com where I added $post[field7] (CD currently being played) to my postbit. I was trying to figure out how to test to see if a user set anything and if they did, display that variable and if they did not, then it would not display at all. Since I couldn't figure it out I had to settle on using (nothing) in my table for field7. Any ideas how to do these things.

In Summary:
1. how Do I add a new bit and then use it in the template system?
2. How do I set a variable in PHP and then use it in the templates?

Thanks.
Aaron

PS. If I can figure these simple things out, whole new worlds of mids will open up to me.
Reply With Quote
  #2  
Old 08-02-2002, 05:01 PM
okrogius okrogius is offline
 
Join Date: Dec 2001
Location: USA
Posts: 264
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<?php

$variable = 'something';

?>
Reply With Quote
  #3  
Old 08-02-2002, 05:06 PM
okrogius okrogius is offline
 
Join Date: Dec 2001
Location: USA
Posts: 264
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

new bit code:

<?php

$bit = eval("all the template proccessing code, lookup form any file");

?>
Reply With Quote
  #4  
Old 08-02-2002, 05:15 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ummm....not sure what you mean. Sorry. I know PHP and I understand eval() but I don't know how you're saying to work this....mind explaining a bit more? Thanks.

Aaron
Reply With Quote
  #5  
Old 08-02-2002, 05:33 PM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am guessing you put the following after maybe if statement or something
Code:
eval("\$aaron = \"".gettemplate('aaron_template')."\";");
in aaron_tempalte it would have the Aaron is cool, and then whatever file you put that in, like index.php put $aaron in the template, and it will say Aaron is cool.

I am taking a shot in the dark here.
Reply With Quote
  #6  
Old 08-02-2002, 05:46 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll try it again, but that's what I thought too and it didn't seem to work. I tried it with like something like $x = 1; without any kind of if/else statement....just plain hardcoded variable, and then did
PHP Code:
eval("\$x = \"".gettemplate('postbit')."\";"); 
and put $x in the template and it didn't seem to do much of anything....nothing was displayed. That's why I'm so confused.

Aaron
Reply With Quote
  #7  
Old 08-03-2002, 08:08 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

LOL....

This SUCKS!

Okay, This is what is in my showthread.php at the very end of the file:
PHP Code:
//*********************Custom Field Hack********************
$tid $thread[postuserid];
$customsql=mysql_query("SELECT * FROM userfield WHERE userid = '$tid'") or die(mysql_error());

while(
$custom=mysql_fetch_array($customsql)){

$field7 $custom['field7'];

if(
$field7 == NULL)
{
$cdnow "";
}
else
{
$cdnow "<b>CD I am Playing:</b> <br>$field7";
}

eval(
"\$cdnow = \"".gettemplate('postbit')."\";");
}
//**********************************************************
eval("dooutput(\"".gettemplate("showthread")."\");");
?> 
And my postbit portion:
PHP Code:
<b>$post[avatar]</b
<
normalfont><br>
   <
b>$post[username]</b>
</
normalfont><br>
<
smallfont>
   
$post[usertitle]<br>
   
$post[hasaward]
</
smallfont><br><br>
   <!---
This was put here to see if $post[field7would get to the page...it does
<smallfont>
   <
b>CD I am Playing:</b>
   <
br>$post[field7]</smallfont>
--->
<!---
this should be what is displayed but it's not --->
[b]$cdnow[/b] 
So how do I get $cdnow to the screen???
Reply With Quote
  #8  
Old 08-03-2002, 08:46 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think this should be at the end of the file :

PHP Code:
//*********************Custom Field Hack********************
$tid $thread[postuserid];
$customsql=mysql_query("SELECT * FROM userfield WHERE userid = '$tid'") or die(mysql_error());

while(
$custom=mysql_fetch_array($customsql)){

if(
$post[field7] == "") {
$cdnow "";
} else {
eval(
"\$cdnow = \"".gettemplate('postbit_cdnow')."\";");
}

//**********************************************************
eval("dooutput(\"".gettemplate("showthread")."\");");
?> 
Then...Create a template called : postbit_cdnow
Contents :
Code:
CD I am Playing:</b><br>$post[field7]
Then in the postbit template, add "$cdnow" where you want it...

Satan
Reply With Quote
  #9  
Old 08-03-2002, 09:37 PM
Sketch Sketch is offline
 
Join Date: Apr 2002
Location: Baltimore, Maryland
Posts: 135
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah I actually changed that in my php al;ready. Still doesn't work. And in the postbit, I am using $cdnow. Notice the $post[field7] deal is in comments...

Aaron
Reply With Quote
  #10  
Old 08-04-2002, 01:19 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try using $post[cdnow] in your postbit. I doubt it matters, but
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 02:00 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.04634 seconds
  • Memory Usage 2,274KB
  • 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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete