View Full Version : php replacement variables
Lizard King
04-04-2005, 11:20 AM
I have a php file working in mo forum and i have a lot of styles. My problem is this php file is calling a template but i have to edit the php file to change background color so it causes a problem with differet styles.
here is the code inside the php file.
################################################## #########################
## SET YOUR OWN COLOURS HERE
################################################## #########################
?>
<body bgcolor="#202020" text="#999999" link="#ff0000" alink="#ff0000" vlink="#ff0000">
<font face="verdana" size="1"><a href="member.php?u=<? echo "$postuserid"; ?>" target="blank">
<b><? echo "$name"; ?></b></a><br><? echo "$comment"; ?><br><br></font></body>
<?
}
is there anyway i can get this to get my style colors ? Maybe with replacement variable but i dont know how to do that.
akanevsky
04-04-2005, 06:13 PM
What you would need to do is instead of hard coding the HTML into the script, make a new template, and call it from the script. In the template, you can put the replacement variables (to see which exactly, check out other templates that have same colors).
Lizard King
04-04-2005, 07:13 PM
I am not really good in coding how can i do that ? can you explain a little more bit ?
akanevsky
04-04-2005, 09:08 PM
To call a template, use this:
$var = fetch_template('template_name');
In the template, you can use template variables. To find out, which variables work, go into your admincp, open the style you need, the go to "style variables". It will open a list of colors, size, etc. If you hover your mouse over a table row with a thing you need, it will popup a variable name in a tooltip - something like $stylevar['something'].
EDIT
Sorry, there are no color variables. To apply the colors etc., use classes. To see which classes have what, go to the CSS part of the template (Style manager -> CSS table). And then just use "class='classuneed'" in HTML.
Lizard King
04-08-2005, 07:55 PM
Is it possible to give you an example what kind of template i need to create ?
$var = fetch_template('adv_portal_shoutbox1');
and then what do i have to edit in adv_portal_shoutbox1 template ?
<body class="tcat"> will this be enough or something else ?
akanevsky
04-08-2005, 09:29 PM
Depends on your objectives.
Lizard King
04-08-2005, 09:36 PM
if i use alt1 for example is the total code i will enter the template will be ?
<body class="alt1"> </body>
or do i have to add something more ?
akanevsky
04-08-2005, 09:50 PM
If you only add <body class="alt1"> </body> to your template, then you can count your template empty - you have nothing except for tags...
Lizard King
04-08-2005, 10:05 PM
If you only add <body class="alt1"> </body> to your template, then you can count your template empty - you have nothing except for tags...
so can you just give an example ? i am not really good in this what i have to add to template ?
The Geek
04-08-2005, 10:25 PM
so can you just give an example ? i am not really good in this what i have to add to template ?
If I understand correctly - you want to be applying the class to the <tr>'s or <td>'s like: <tr class='alt1'> or <td class='alt1'>
i would avoid putting it in the body declaration. Its a bit too global for my tastes. It would help if you could specify exactly what you were trying to do though.
HTH's
akanevsky
04-08-2005, 10:54 PM
I cannot help you until I know what exactly do you want to see as a result.
Lizard King
04-08-2005, 11:02 PM
I have a shoutbox module for vbadvanced Cmps. The module is really simple. It only uses 1 php file and 1 template.
Here is the php file :
<?php
################################################## #########################
## MAJESTIC FORUM SHOUTBOX
################################################## #########################
################################################## #########################
## REQUIRE BACK-END
################################################## #########################
require_once('./global.php');
function check($var,$link)
{
$var = trim($var);
if(empty($var))
{
header("Location: $link");
}
}
function swear()
{
global $comment;
$swears["++++"] = "++++";
$swears["++++ing"] = "++++ing";
$swears["++++"] = "++++";
$swears["+++++"] = "+++++";
while(list($text,$image) = each($swears))
{
$comment = str_replace("$text","$image","$comment");
}
return $comment;
}
function replace_text_smiley() {
global $comment;
$faces["text smiley here"] = "img tag to image smile here";
$faces[":lol:"] = "<img src=\"http://forum.ayyas.com/images/smilies/cool.gif \" alt=\"Cool\">";
while(list($text,$image) = each($faces)) {
$comment = str_replace("$text","$image","$comment");
}
return $comment;
}
################################################## #########################
## CONDITION ONE
################################################## #########################
$is = "view";
if(isset($setting) && !empty($setting) && $setting == "save") {
################################################## #########################
## HEAD INFO
################################################## #########################
$back = $HTTP_REFERER;
################################################## #########################
## CHECK DO
################################################## #########################
if($is == "ref") {
header("Location: shoutbox.php");
}
################################################## #########################
## CHECK SHOUTBOX STOP NON REGISTERED POSTING
################################################## #########################
check($name,$back);
check($comment,$back);
if($bbuserinfo[username]!=$name || $bbuserinfo[userid]==1)
{
?>
<font face="Verdana" size="1">
<?echo('Vur Kac a yazabilmeniz icin kayit olmaniz gerekiyor.');?>
</font>
<?
exit;
}
################################################## #########################
## SAVES SHOUTBOX
################################################## #########################
$user=$bbuserinfo[userid];
if(!mysql_query("INSERT INTO adv_shoutbox (name,comment,postuserid) VALUES ('$name','$comment','$user')")) {
$url = 'shoutbox.php?is=save';
header("Location: $url");
} else {
################################################## #########################
## LIMIT SHOUTS TO STOP IT FILLING DATABASE [$maxi - 100] <--- CHANGE THIS TO YOUR LIMIT
################################################## #########################
$res = mysql_query("SELECT max(id) FROM adv_shoutbox");
$maxi = mysql_result($res, 0);
mysql_query("DELETE FROM adv_shoutbox WHERE id < ($maxi - 200)");
header("Location: shoutbox.php");
}
}
if(empty($setting) || $setting == "view") {
################################################## #########################
## DISPLAY SHOUTS FROM TABLE
################################################## #########################
$result = mysql_query("SELECT * FROM adv_shoutbox ORDER BY id DESC LIMIT 100") or die (mysql_error());
$num_res = mysql_num_rows($result);
if($num_res == "0") {
echo 'There are no shouts yet.';
?>
<form action="shoutbox.php" method="post">
<input type="hidden" name="setting" value="save">
<input type="text" name="name" value="name">
<br /><input type="text" name="comment" value="comment">
<br /><input type="submit" value="Shout"></form>
<?
} else {
while ($get = mysql_fetch_row($result)) {
$name = $get[1];
$comment = $get[2];
$postuserid = $get[3];
$name = strip_tags($name);
$comments = strip_tags($comments);
$comment = nl2br($comment);
replace_text_smiley();
swear();
################################################## #########################
## SET YOUR OWN COLOURS HERE
################################################## #########################
?>
<body bgcolor="#060606" text="#999999" link="#ff0000" alink="#ff0000" vlink="#ff0000">
<font face="verdana" size="1"><a href="member.php?u=<? echo "$postuserid"; ?>" target="blank">
<b><? echo "$name"; ?></b></a><br><? echo "$comment"; ?><br><br></font></body>
<?
}
}
}
################################################## #########################
## CONDITION THREE BAN ERROR
################################################## #########################
if($is == "ban") {
echo 'You are banned from the shoutbox. So just leave now.';
exit;
}
################################################## #########################
## CONDITION FOUR ERROR ON SHOUT
################################################## #########################
if($is == "save") {
echo 'There was an error in saving your shoutbox.';
exit;
}
################################################## #########################
## MAJESTIC FORUM SHOUTBOX
################################################## #########################
?>
and the template it is using is :
<!-- Shoutbox -->
<script type="text/javascript">
var timer_id;
function scroll_iframe(frm,inc,dir) {
if (timer_id) clearTimeout(timer_id);
if (window.frames[frm]) {
if (dir == "v") window.frames[frm].scrollBy(0, inc);
else window.frames[frm].scrollBy(inc, 0);
timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
}
}
function stopScroll() { if (timer_id) clearTimeout(timer_id); }
</script>
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder"width="100%">
<tr><td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] $mods[title]</strong></span>
<a href="javascript:;" onmouseover="scroll_iframe('shoutbox', -4, 'v'); window.status='Hover here to scroll up.'; return true" onmouseout="stopScroll(); window.status=''; return true"><img src="http://forum.ayyas.com/images/tri-up.gif" valign="top" align="right" width="12" height="12" alt="Yukarı" border="0"></a></td></tr>
<tr><td class="alt1"><span class="smallfont">
<DIV ID=oDiv STYLE="width: 158px; height: 254px; overflow: hidden;">
<iframe class="alt1" marginwidth="2" marginheight="2" name="shoutbox" noresize scrolling="no" align="middle" frameborder="0" height="250" width="100%" src="forum/shoutbox.php" id="shoutbox"></iframe></DIV>
<form action="forum/shoutbox.php" method="post" target="shoutbox">
<input type="hidden" name="setting" value="save" />
<input type="hidden" name="name" value="$bbuserinfo[username]" size="20" />
<input type="text" name="comment" value="eşeğim ben" size="20" maxlength="100" /><br>
<input class="button" type="submit" value="Bağır ?ağır" /></form></span>
<a href="javascript:;" onmouseover="scroll_iframe('shoutbox', 4, 'v'); window.status='Hover here to scroll down.'; return true" onmouseout="stopScroll(); window.status=''; return true"><img src="//forum.ayyas.com/images/tri-dn.gif" valign="top" align="right" width="12" height="12" alt="Aşağı" border="0"></a></td></tr></table><br />
<!-- Shoutbox -->
You can see it here : www.ayyas.com it matches the style cause i can edit it from the php file but i have other styles and there is no way i can get it working.
check another style to see : http://www.ayyas.com/?styleid=39
why-not
04-09-2005, 12:57 AM
Hi
You are calling a include on './global.php'
So you have all your style var(s) ready to be accessed! I don't know what CSS style var(s) you want to use, but you can decide by just doing this!
To see what colors you want to use....
PUT THIS IN YOUR SCRIPT!
print_r ( $stylevar );
That will print an array like this! (example only contains a few elements of the array)
Array
(
[body_fgcolor] => #2d24c6
[page_bgcolor] => #ffffff
[page_fgcolor] => #B9B9B9
[tborder_bgcolor] => #7a89ea
[tborder_fgcolor] => #ffffff
[tcat_bgcolor] => #7a89ea
[tcat_fgcolor] => #f9f95b
[thead_bgcolor] => #fafa86
[thead_fgcolor] => #372fd9
[tfoot_bgcolor] => #F9F9F9
[tfoot_fgcolor] => #372fd9
[alt1_bgcolor] => #ffffff
[alt1_fgcolor] => #000000
[alt2_bgcolor] => #ffffff
[alt2_fgcolor] => #000000
[wysiwyg_bgcolor] => #ffffff
[wysiwyg_fgcolor] => #000000
[smallfont_fgcolor] => #000000
[time_fgcolor] => #000000
[navbar_fgcolor] => #000000
[highlight_fgcolor] => #FF0033
[fjsel_bgcolor] => #ffffff
[fjsel_fgcolor] => #655de1
[fjdpth0_bgcolor] => #f7f7f7
[fjdpth0_fgcolor] => #000000
[panel_bgcolor] => #ffffff
[panel_fgcolor] => #000000
[panelsurround_bgcolor] => #fafa86
[panelsurround_fgcolor] => #000000
[legend_fgcolor] => #372fd9
[vbmenu_control_bgcolor] => #fafa86
[vbmenu_control_fgcolor] => #655de1
[vbmenu_popup_bgcolor] => #ffffff
[vbmenu_popup_fgcolor] => #655de1
[vbmenu_option_bgcolor] => #fafa86
[vbmenu_option_fgcolor] => #655de1
[vbmenu_hilite_bgcolor] => #ffffff
[vbmenu_hilite_fgcolor] => #655de1
)
Then just select the style var(s) you want to use... (remember to remove [print_r ( $stylevar );] after getting the array that you will use as your guide!)
example....
################################################## #########################
## SET YOUR OWN COLOURS HERE
################################################## #########################
?>
<body bgcolor="<?=$stylevar['thead_bgcolor'];?>" text="<?=$stylevar['thead_fgcolor'];?>" link="<?=$stylevar['thead_fgcolor'];?>" alink="<?=$stylevar['tfoot_fgcolor'];?>" vlink="<?=$stylevar['thead_fgcolor'];?>">
<font face="verdana" size="1"><a href="member.php?u=<? echo "$postuserid"; ?>" target="blank">
<b><? echo "$name"; ?></b></a><br><? echo "$comment"; ?><br><br></font></body>
<?
}
Sonia
Lizard King
04-09-2005, 01:24 AM
Thanks Sonia :) Finally I get this working :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.